Page 225 - Computer science 868 Class 12
P. 225
System.out.println(p);
}
(i) What will be the output of the method trick() when the values of a=3 and b=4? [ISC 2022]
(a) 12 (b) 127
(c) 81 (d) 64
Ans. (c)
(ii) What is the method trick() computing? [ISC 2022]
(a) Factorial of a number (b) Product of the numbers
(c) Power of a number raised to a number (d) HCF of the two numbers
Ans. (c)
4. With reference to the following program code, answer the questions that follow:
void funny(int p,int m, int n)
{ for(int i=p;i<=p;i++)
{ switch(i)
{ case 1 : m+=10;
case 2 : n- = 1; break;
case 3 : m+=n;n+=3;break;
default: m+=2 ;
}
System.out.println(m+":" +n);
}
}
(i) What will be the output of the method funny() when the values of p=1, m=12 and n=6? [ISC 2022]
(a) 20:4 (b) 22:5
(c) ERROR (d) 24:7
Ans. (b)
(ii) What is the keyword used in Java to avoid a fall through condition? [ISC 2022]
(a) case (b) continue
(c) switch (d) break
Ans. (d)
5. With reference to the following program code, answer the questions that follow:
void play(int n)
{ int s=0;
while (n!=0)
{ s=s* 10 + n-(n/10)*10;
n/=10;
}
System.out.println(s);
}
(i) What will be the output of the method play() when the value of n=6957? [ISC 2022]
(a) 27 (b) 695
(c) 5679 (d) 7596
Ans. (d)
(ii) What is the method play() performing? [ISC 2022]
(a) Arranging the digits in ascending order (b) Reversing the number
(c) Extracting the first 3 digits (d) Sum of the digits
Ans. (b)
6. The following is an if-else code. [ISC 2022]
if(x!=y)
P=x+y;
else
P=12 ;
What is the representation of the above code in ternary form? [ISC 2022]
(a) P=(x!=y)? x+y,12; (b) P=(x!=y)? P=x+y: P=12;
(c) P=(x!=y)? x+y : 12; (d) P=(x!=y) x+y, 12;
Ans. (c)
223
Statements and Scope 223

