Java OCA OCP Practice Question 1147

Question

What is the output of the following?

12:  int v = 8; 
13:  for: while (v > 7) { 
14:     v++; 
15:     do { 
16:        v--; 
17:     } while (v > 5); 
18:     break for; 
19:  } 
20:  System.out.println(v); 
  • A. 5
  • B. 8
  • C. The code does not compile.
  • D. The code compiles but throws an exception at runtime.


C.

Note

The label of the loop is trying to use the keyword for.

This is not allowed, so the code does not compile.

If the label was valid, Option A would be correct.




PreviousNext

Related