Given:
public class Main { public static void main(String[] args) { int x = 4;/*from ww w . j av a 2 s. c om*/ int y = 4; while ((x = jump(x)) < 8) do { System.out.print(x + " "); } while ((y = jump(y)) < 6); } static int jump(int x) { return ++x; } }
What is the result?
B is correct.
It's legal for while expressions to include method calls.
The do loop is nested inside the while loop.
In the first iteration of the while loop, the do loop is executed twice, and "y" is left with the value of 6.
In subsequent while iterations, the do loop executes only once because "y" just keeps getting bigger and bigger.