What is the output of the following java code? int m = 1000;
What is the output of the following java code?
int m = 1000;
int k = 3000;
while (++m < --k);
System.out.println(m);
Show answerHide answer
Correct answer: (C) 2000
Explanation
Each test increments m and decrements k. The loop stops when m >= k, which first happens at m = 2000, k = 2000 (1000 iterations). So 2000 is printed.