Multiple choice java

int x = 10;
do {
 x--;
} while (x < 10);

How many times the loop will be executed?

  1. ten times

  2. zero times

  3. one to nine times

  4. more than ten times

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

The do-while loop executes at least once, then checks the condition. Initially x=10, after first iteration x=9. The condition 'x < 10' is true (9<10), so the loop continues. This creates an infinite loop - it will execute more than ten times until manually stopped or the program crashes.