Dry Run 10
Dry Run 10
=b) || (b<4))
for(i=5;i>=1;i--) System.out.println(“Incredible”+” System.out.println(a+b);
{ \n”+”world”); else if((a>b) && (b<5))
if(i%2==1) System.out.println(a*b);
continue; else
System.out.print(i+” “); System.out.println(a%b);
}
If i)a=16,b=12 ii)a=27,b=28
d) int i; e)Write the value of d:- f) int a,b;
for(i=5;i>10;i++) a=25,b=35,c=11; for(a=6,b=4;a<=24;a=a+6)
System.out.println(i); i)d=!(a==0||a>b || !(b<0)); {if(a%b==0)
System.out.print(i*4); ii)d=!(a>b)&&(a<b&&b>0); break;
}
System.out.println(a);
2) void find(int a,int b) 3) If a parameterised constructor 4) What is the output of the following:
{int p=1; Abc(double num,short a) exists in String a="Java is programming language \
for(int j=1;j<=b;j++) a class,which of the following n developed by \t\'James Gosling\'";
p=p*a; valid java statement calls this System. out. println(a);
System.out.println(p); constructor implicitly:-
} a)ABC obj=new();
If find(5,3) is invoked b)ABC obj=new ABC(5.52,2);
c)Abc obj=new Abc(10.89,4);
d)All of the above
5) What is the value of m after evaluating the 6) Predict output of the following: 7) Give the output of the following java
following expression: m - = 9%++n + ++n/2; (i) statements: (i)
when int m=10,n=6 Math.pow(25,0.5)+Math.ceil(4.2) "TRANSPARENT".toLowerCase(); (ii)
(ii) Math.round ( 14.7 ) + "TRANSPARENT".compareTo("TRANSITION
Math.floor ( 7.9) ")
8) What will be the output of the following 9) What will be the output of the 10) int a[]=new int[3];
program segments? following program segments? int i,j,c=10;
(i) String s = “application”; (i) String s = “Loyola school”; for(i=0;i<3;i++)
int p = s.indexOf(“a”); int p = s.indexOf(“a”); a[i]=2*c++;
System.out.println(p); System.out.println(p); for(i=a.length-1;i>=0;i--)
System.out.println(p+s); System.out.println(p+s); System.out.println(a[i]+"\t"+2*a[i]);
(ii) String st = “PROGRAM”; (ii) String st = “Bhubaneswar”;
System.out.println(st.indexOf(st.charAt(4))) System.out.println(st.indexOf(st.c
harAt(4)))
11) Find the output:- 12) int a=2,b=3,c=9; 13) int i,j;
static void Result(int num) c*=a--+ ++b*++c; for(i=10;i>=2;i-=2)
{int System.out.println(a+” “+b+” “+c); {for(j=i;j>=2;j-=2)
s=num*num,c=s*num;System.out.println(s);} {System.out.print(i*j);
static int call(int y) }System.out.println();}
{return y*y-y;}
static void main()
{int z=call(4);Result(z);}
14)class Exam 15) Write the output of: {int 16) int n=6,s=0;
{ int a=0,b=0; a=6,b=8,c=10,d=15; int f=a++ - (-- for( int i=1;i<=2;i++)
void Test(int c){a=5;b=c; b)*c--+ --d; for(int j=1;j<n;j++)
System.out.println("A="+a); System.out.println(a+” “+b+” if(n%j==0)
System.out.println("B="+b);} “+c+” “+d+ “ “+f); s+=j;
public void main() System.out.println(s);
{
Exam E1=new Exam(); a=16;b=25; int d=42;
System.out.println("a+b"+a+b); E1.Test(9);
d=a+b; System.out.println("Value of d="+d);
Write the output of the above code.
17) class point 18) int check(int x,int y) 19) Write the output:-
{int x,y; {int a,s,l; String s1=”jolly”; String s2=”fellow”;
point(int a,int b) if(x<y) System.out.println(s1.substring(0).concat(
{x=a;y=b;} {s=x;l=y;} s2.substring(2)));
void midpoint(point p,point q) else System.out.println(s2.toUpperCase());
{this.x=(p.x+q.x)/2; {s=y;l=x;}
this.y=(p.y+q.y)/2;} a=l;
void display() while(a%s!=0)
{System.out.println("Mid point {a+=1;}
coordinates"+x+"&"+y);} return a;}
public static void main() i)What value will be returned for
{point ob1=new point(50,100); function check(6,5)
point ob2=new point(10,20); ii)Write the main block to send
ob2.midpoint(ob1,ob2); the values and print the returned
ob2.display();}} value.
a) rewrite into if:- b)rewrite into multiple branching c)rewrite into ternary:-
int max=((a>b)&&(a>c))?a:((b>a)&&(b>c))?b:c; statement:- if(c==true)
If(cate==’a’) p+=(d*v);
type=”agricultural”; else
else if(cate==’d’) p-=(d*v);
type=”domestic”;
else if(cate==’c’)
type=”commercial”;
else
type=”personal”;
d)Rewrite into if-else-if :- e) rewrite into for:- f)write a prototype for function chk,
switch(code) char ch; which accepts two string parameters
{case ‘0’:System.out.println(“zero);break; int x=65; and returns the length of the longer
case ‘1’: do{ch=(char)x;System.out.print(ch+” “); string.
case ‘2’:System.out.println(“one and two”); if(x%10==0)
default:System.out.println(“None”);} break;
++x;
}while(x<=100);
g)Rewrite the following loop using for loop: h) Write the prototype of a function i) Write a statement in Java for
while (true)
System.out.print("*");
search which takes two arguments a
string and a character and returns an
√ a+b3
integer value.
¿ a−b∨¿ ¿
j) Write a java statement for each to perform k) Write a statement in Java for l)Write a statement to check if the 1st
the following task: (i) Find and display the 1 2 3 character in a string str,is blank.
r+
position of the last space in a string str. (ii) 3 x
Extract the second character of the string str.
m) Correct the errors:- n)rectify:- o) )Rewrite the following decision
Void meth1() int max=(a>b)?(a>c)?a:b:c; making statements using conditional
{String s=”work on your strengths”; operator:-
String ex=s.substring(9,10); i)if(x>0) flag=1;
If(ex==” “) else flag=0;
System.out.println(“Bingo”); ii)if(m==0)
Else System.out.print(“Hello”);
System.out.println(“OHHH!”); else System.out.print(“Good Day”);
p) Write java expression for the following:- q) Rewrite using more than one –if:- r) Rewrite using multiple branching
√ (p−a)( p−b)( p−c) if(tm>250 && em>80 && mm>95) statement:
a)r= b)v= e=’y’;else e=’N’; if(code=’A’)
3
c)Rewrite using ‘while’: a=”Accountant”;
5 x 3+2 y
{m=1;n=0; elseif(code==’c’||code==’G’)
x+ y for( ;m+n<19;n++) a=”Grade-iv”;
{Sopln(“Hello”);m+=10;} else
a=”Financial Advisor”;