What the following part of the code will type:

int x = 0;
int y = 10;
do {
    y--;
    ++x;
} while (x < 5);
System.out.print(x + "," + y);
Explanation
Iterations
1: x=1 y=9
2: x=2 y=8
3: x=3 y=7
4: x=4 y=6
5: x=5 y=5 - loop exits

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes