1Z0-811 Control Flow and Loops Practice Question
Exhibit
Refer to the exhibit.
for (int i = 0; i < 5; i++) {
if (i == 2) {
continue;
}
System.out.print(i + " ");
}What is the output of the code?
```java
for (int i = 0; i < 5; i++) {
if (i == 2) {continue;
}
System.out.print(i + " ");
}
```
⚠ Common exam trap
The trap here is that candidates may forget that continue skips only the current iteration, not the entire loop, leading them to think the loop stops entirely or to misplace the starting value.
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 1 3 4
The code uses a for loop that iterates from i = 0 to i < 5 (i.e., 0 through 4). Inside the loop, there is an if condition that checks if i equals 2. When i == 2, the continue statement is executed, which skips the rest of that iteration, so the System.out.print statement is not executed for i = 2. Therefore, the loop prints 0, 1, 3, and 4, each followed by a space. Option D correctly lists this output.
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 1 2 3 4
Why it's wrong here
Includes 2.
- ✗
1 3 4
Why it's wrong here
Missing 0.
- ✗
0 1 2 3
Why it's wrong here
Missing 4 and includes 2.
- ✓
0 1 3 4
Why this is correct
Correct output.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 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-811 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-811 exam.