What is the output of the following?
public class Main { public static void main(String[] args) { boolean v = false; do {//from w ww .ja v a 2s. co m if (!v) { v = true; System.out.print("inflate-"); } } while (!v); System.out.println("done"); } }
B.
This is a correct do-while loop.
On the first iteration of the loop, the if statement executes and prints inflate-.
Then the loop condition is checked.
The variable v is true, so the loop condition is false and the loop completes.