MCQs
Total Questions : 42
| Page 2 of 5 pages
Answer: Option D. -> All of the above
Answer: Option C. -> Repeatedly print 1 2 3 and cause infinite loop.
Answer: Option B. -> 1
Answer: Option A. -> true
Question 15. What all gets printed when the following program is compiled and run.
public class Test{
public static void main(String args[]){
int i, j=1;
i = (j>1)?2:1;
switch(i){
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}
public class Test{
public static void main(String args[]){
int i, j=1;
i = (j>1)?2:1;
switch(i){
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}
Answer: Option E. -> 1 2
Answer: Option C. -> 2
Answer: Option D. -> 0
Answer: Option C. -> int y = 11;
Answer: Option D. -> 13
Answer: Option C. -> Compilation fails.
The code will not compile because a continue statement can only occur in a looping
construct. If this syntax were legal, the combination of the continue and the if statements
would create a kludgey kind of loop, but the compiler will force you to write cleaner code
than this.