Java OCA OCP Practice Question 1134

Question

Fill in the blank so this code compiles and does not cause an infinite loop.

t: while (true) { 
        f: while(true) { 
            ______
        } 
} 
  • A. break;
  • B. break f;
  • C. break t;
  • D. None of the above


C.

Note

Option A breaks out of the inner loop, but the outer loop is still infinite.

Option B has the same problem.

Option C is correct because it breaks out of both loops.




PreviousNext

Related