1Z0-829 Controlling Program Flow Practice Question
Exhibit
Refer to the exhibit.
```java
public class LoopExample {
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 == 2) {
break outer;
}
System.out.print(i + " " + j + " ");
}
}
}
}
```Refer to the exhibit. What is the output when the program is executed?
⚠ Common exam trap
Oracle OCP Java 17 often tests the distinction between a simple break (which exits only the innermost loop) and a labeled break (which exits the specified outer loop), causing candidates to mistakenly assume the inner loop continues or the outer loop resumes.
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 1 1
The code uses nested for loops with break labels. The outer loop iterates i from 0 to 2, and the inner loop iterates j from 0 to 2. When i == 1 and j == 1, the break outer; statement exits both loops, so after printing 0 0, 0 1, 0 2, 1 0, 1 1, the program terminates. This matches option C.
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
Why it's wrong here
Includes the (1,2) pair incorrectly.
- ✗
0 0 0 1 0 2 1 0 1 1 2 0 2 1 2 2
Why it's wrong here
Missing break effect; continues outer loop after i=2.
- ✓
0 0 0 1 0 2 1 0 1 1
Why this is correct
Correct output: prints all pairs until (1,2) triggers the break.
- ✗
0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2
Why it's wrong here
This would be the output without the break.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.