?
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?
public class Test{
public static void main(String [] args){
int x = 0;
// insert code here
do{ } while(x++ < y);
System.out.println(x);
}
}
Answer & Solution
Correct Answer:
Option
C
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.
Join the Discussion
Login to post a comment or share your explanation.
Login