D

Deepak Sahoo • 10.78K Points
Tutor II

Q. What is the output of the following code?

Code:
int x = 0;
do {
System.out.println(x);
x++;
} while (x < 5);
  • (A) 0 1 2 3 4
  • (B) 1 2 3 4 5
  • (C) 0 1 2 3
  • (D) 1 2 3 4
  • Correct Answer - Option(A)
  • Views: 77
  • Filed under category JAVA

Explanation by: Deepak Sahoo
The do-while loop prints the value of x on each iteration until x becomes greater than or equal to 5.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics