Question #235162

What does the following code output?

int x=8;
int y=2;
while (x>8) {

x--;
y+=2;
}

System.out.println (y)

Expert's answer

The condition in the while loop is false (x > 8 is false), so y does not change, and the output is 2.


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS