What is the output of the following?
boolean v = false; do { if (!v) { v = true; System.out.print("v-"); } } while (v); System.out.println("done");
D.
On the first iteration of the loop, the if statement executes printing v-.
Then the loop condition is checked.
The variable v is true, so the loop condition is true and the loop continues.
The if statement no longer runs, but the variable never changes state again, so the loop doesn't end.