You are on page 1of 1

Q.1.

Write the dry-run and output:-

a)x + = x++ + ++ x + --x + x; [ x = 5 ] b) if ( a > b ) c) String x = (a >= 90) ? d)switch ( x ) e)int a=7,b=8;
System.out.println(a+b); "excellent" : "best"; { case 'a' : int c=a--/b++ * ++a%--b;
System.out.println when a = 90 System.out.println("Discipline"); System.out.println(a+”*”+b+”*”+c);
(a*b); when a = 5 and b case 'b' : System.out.println
=7 ("Dedication"); break;
case 'c' :
System.out.println("Commitment");
default :
System.out.println("Success"); }
when i) x='A' ii)x=’b’ iii)x=’a’
f) g) if((a!=b) || (b==4)) h) Write the value of d:- i) ) int a=2,b=3,c=9; j) int a=6,b=8,c=10,d=15;
System.out.println(“Computer”+”\’”+”applications”); System.out.println(a+b); a=45,b=32,c=10; c*=a--+ ++b*++c; int f=a++ - (--b)*c--+ --d;
else if((a<b) && (b<5)) i)d=!(a==0||a>b || !(b<0)); System.out.println(a+” “+b+” “+c); System.out.println(a+” “+b+” “+c+” “+d+ “
System.out.println(a*b); ii)d=!(a>b)&&(a<b&&b>0); “+f);
else
System.out.println(a%b);

If i)a=26,b=45 ii)a=12,b=18
Q.2. Do as directed:-

a)Identify if the following form valid or invalid identifiers giving reasons for the same:-

i)JACK^& ii)po90 iii)$_toy iv)sack v)lol$^

b)Write java expressions for the following:-

4 3√3 2 1 −𝑏+√𝑏2 −4𝑎𝑐


i)3π𝑟 3 ii)√𝑠(𝑠 − 𝑎)(𝑠 − 𝑏)(𝑠 − 𝑐) iii) X𝑎 iv) 3π𝑟 2 h v)
2 2𝑎
c)Rewrite:-

i)into switch:- ii) rewrite into ternary:- iii) Rewrite the following decision iv) Convert the following if- v) Rewrite the following using
if(cate==’a’) if(c==true) making statements using conditional else-if construct into switch logical operators:-
type=”agricultural”; p+=(d*v); operator:- case:- if(x>5)
else if(cate==’d’) else i)if(x>0) flag=1; if(ch=’c’||ch==’C’) if(x>y)
type=”domestic”; p-=(d*v); else flag=0; Sytem.out.print(“COMPUTER”); System.out.println(x+y);
else if(cate==’c’) ii)if(m==0) else if(ch=’h’||ch==’H’)
type=”commercial”; System.out.print(“Hello”); Sytem.out.print(“HINDI”);
else else System.out.print(“Good Day”); else
type=”personal”; System.out.print(“PHYSICAL

You might also like