1Z0-829 unlabeled break Practice Question
Exhibit
Refer to the exhibit.
public class LoopTest {
public static void main(String[] args) {
outer: for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i == 1 && j == 1) continue outer;
System.out.print(i + "," + j + " ");
}
}
}
}What is the output?
⚠ Common exam trap
Candidates often confuse unlabeled break with labeled break. An unlabeled break exits only the innermost enclosing loop, while a labeled break exits the loop marked by the label. Here, the break is unlabeled, so after '1,0' the outer loop continues.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
0,0 0,1 0,2 1,0 2,0 2,1 2,2
The code uses an unlabeled 'break;' inside the inner loop when i==1 and j==0. This break exits only the inner loop, not the outer loop. Therefore, for i=1, after printing '1,0', the inner loop terminates and the outer loop continues to i=2, where j iterates 0,1,2 printing '2,0 2,1 2,2'. For i=0, j prints all three values. Thus the output is '0,0 0,1 0,2 1,0 2,0 2,1 2,2'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2
Why it's wrong here
Incorrect. This option includes all combinations from i=0 to 2 and j=0 to 2, but the labeled break when i=1 and j=0 exits the outer loop, so combinations with i=1 and j>0 are not printed.
- ✗
0,0 0,1 0,2 1,0
Why it's wrong here
Incorrect. Although the text matches the correct output, this option is marked as wrong due to a duplication error. The actual correct output is given in option C.
- ✓
0,0 0,1 0,2 1,0 2,0 2,1 2,2
Why this is correct
Correct. The output correctly reflects the labeled break: i=0 prints all j, i=1 prints only j=0 then breaks, i=2 prints all j, resulting in '0,0 0,1 0,2 1,0 2,0 2,1 2,2'.
- ✗
0,0 1,0 2,0
Why it's wrong here
Incorrect. This option only prints combinations with j=0, missing the iterations where i=0 and j=1,2 and i=2 and j=1,2.
Go deeper
Related to this question
About these practice questions
This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.