Q48
public class Test public static void main(String [] args) int x = 0; // insert code here do while(x++ < y); System.out.println(x); Which option, inserted at line 4, produces the output 12?
A.
int y = x;
B.
int y = 10;
C.
int y = 11;
AnswerD.
int y = 12;
E.
None of the above will allow compilation to succeed.
Answer: Option C
Solution
Answer: Option C
Solution:
x reaches the value of 11, at which point the while test fails.
x is then incremented (after the comparison test!), and the println() method runs.
Hence, choice A, B, D, E, and F are incorrect based on the above point.