Multiple choice java

int x = 12;  
while (x < 10) {  
   x--;  
}  
System.out.print(x); 

What is the result?

  1. 0

  2. 10

  3. 12

  4. print statement never be executed

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

The while loop condition (x < 10) is false initially since x = 12. The loop body never executes, so x is never decremented and remains 12. The print statement outputs 12, not 0 or 10.

AI explanation

To answer this question, let's go through the code step by step:

  1. The code initializes the variable x with the value 12.
  2. The while loop condition is x &lt; 10. Since x is initially 12, the condition is false, and the code inside the while loop will not be executed.
  3. After the while loop, the code prints the value of x, which is 12.

Therefore, the result of the code is 12.

The correct answer is option C.