You are on page 1of 2

a)int i; b) c) if((a!

=b) || (b<4))
for(i=5;i>=1;i--) System.out.println(“Incredible”+”\n”+”world”); System.out.println(a+b);
{ 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);

g)class a h) if(a<b) i) {if(code==1)


{public static void main() {if(b!=2) System.out.println(“single digit ”);
{ int m=5,n=2,p=m*n; {c=a+b;} else if(code==11)
if(m>p) else{c=a-b;}} System.out.println(“double digit”)
System.out.println(m*m); else else
else c=a*b; System.out.println(“it is a special
System.out.println(m*p); System.out.println(c);} character”);}
If i)a=16,b=22 ii)a=27,b=18
}} i)code =1 ii)code=11 iii)code=214
iv)code=7167
j)Write the dry-run and output:- k) char ch=’F’; l) int i=1;int d=5;
int a=6,b=8,d=9;boolean x; int m=ch; do{
x=!(!((a>b)&&(a>d))); m=m+5; d=d*2;
System.out.println(x); System.out.println(m+” “+ch); System.out.println(d);
i++;
}while(i<=5);

m) for(int i=3;i<=4;i++) n) int m=5,n=10; o) for(int m=5;m<=20;m+=5)


{for(int j=2;j<i;j++) while(n>=1) {if(m%3==0)
{System.out.print(“”);} {System.out.println(m*m); break;
System.out.println(“WIN”);} n--; else
} if(m%5==0)
System.out.println(m);
continue;
}

p) char ch; q) System.out.println(“The king said\”Begin at r) int x=2,y=50;


int x=65; the beginning!\”to me.”); do{++x;y-=x++;}while(x<=10);
do{ch=(char)x;System.out.print(ch+” “); System.out.println(y);
if(x%10==0)
break;
++x;
}while(x<=100);

s) int i,sum=0; t) u) What is the output of the following:


for(i=1;i<=9;i+=2); int b=5;int c=5; String a="Java is programming language
System.out.println(i); c*=b++ - (--b)/8; \n developed by \t\'James Gosling\'";
System.out.println(“sum=”+sum); System. out. println(a);
v) int a=8,b=10,c=15 ; x)int p=1,a=5,b=3; y) What is the value of m after
a+=a++ + (- - a + c++)+b%a; for(int j=1;j<=b;j++) evaluating the following expression: m -
System.out.println(a+”,’+b+”,”+c);} p=p*a; = 9%++n + ++n/2; when int m=10,n=6
System.out.println(p);
z) Predict output of the following: 1) ) int a=2,b=3,c=9; 2) Write the output of: {int
(i) Math.pow(25,0.5)+Math.ceil(4.2) (ii) c*=a--+ ++b*++c; a=6,b=8,c=10,d=15; int f=a++ - (--b)*c--+
Math.round ( 14.7 ) + Math.floor ( 7.9) System.out.println(a+” “+b+” “+c); --d;
System.out.println(a+” “+b+” “+c+” “+d+
“ “+f);
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 statement in Java for
switch(code) char ch; √𝑎 + 𝑏3
{case ‘0’:System.out.println(“zero);break; int x=65; |a − b|
case ‘1’: do{ch=(char)x;System.out.print(ch+” “);
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 a statement in Java for i) Rewrite the following decision making
while (true) 1 2 statements using conditional operator:-
𝑟 +𝑥 3
3
System.out.print("*"); i)if(x>0) flag=1;
else flag=0;
ii)if(m==0)
System.out.print(“Hello”);
else System.out.print(“Good Day”);

j) Write java expression for the following:- k) rectify:- l) Rewrite using multiple branching
a)r=
√(𝑝−𝑎)(𝑝−𝑏)(𝑝−𝑐)
b)v=
5𝑥3+2𝑦 int max=(a>b)?(a>c)?a:b:c; statement:
3 𝑥+𝑦 if(code=’A’)
a=”Accountant”;
elseif(code==’c’||code==’G’)
a=”Grade-iv”;
else
a=”Financial Advisor”;
m) Rewrite using more than one –if:- n) Convert the following if-else-if o) Rewrite the following using
if(tm>250 && em>80 && mm>95) construct into switch case:- logical operators:-
e=’y’;else e=’N’; if(ch=’c’||ch==’C’) if(x>5)
c)Rewrite using ‘while’: Sytem.out.print(“COMPUTER”); if(x>y)
{m=1;n=0; else if(ch=’h’||ch==’H’) System.out.println(x+y);
for( ;m+n<19;n++) Sytem.out.print(“HINDI”);
{Sopln(“Hello”);m+=10;} else
System.out.print(“PHYSICAL
EDUCATION”);

You might also like