Multiple choice technology programming languages

class Demo { public static void main(String [] args) { int x = 0; // insert code here do { } while (x++ < y); System.out.println(x); } } Which, inserted at line 4, produces the output 12?

  1. int y = x;

  2. int y = 10;

  3. int y = 11;

  4. None of the above will allow compilation to succeed.

  5. int y = 12;

  6. int y = 13;

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The do-while loop executes the body first, then checks the condition x++ < y. With y=11 and x starting at 0: x increments to 1 and 1<11 is true (loop continues). This continues until x becomes 11: x increments to 12 and 12<11 is false (loop exits). At exit, x=12, which is printed. Each iteration increments x after the comparison.