1Z0-829 Controlling Program Flow Practice Question
A developer is implementing a batch processing application that reads records from a list and processes them. The method uses a for loop with an index variable. Inside the loop, if a record is null, the developer wants to skip that iteration and continue with the next index. The developer writes: for (int i = 0; i < records.size(); i++) { if (records.get(i) == null) continue; process(records.get(i)); updateCounter(); } However, the counter is not updated correctly. The developer expects the counter to reflect the number of processed (non-null) records. What is the problem?
⚠ Common exam trap
It's easy for candidates to think `continue` only affects the current iteration's processing but forget that it also skips all subsequent statements in the loop body, including counter updates, leading them to choose options like A or D instead of recognizing the control flow issue.
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
✓
The continue statement skips the rest of the loop body, including the counter update.
The `continue` statement immediately jumps to the next iteration of the loop, skipping any remaining code in the current iteration. In this case, `updateCounter()` is placed after the `continue` in the loop body, so when a null record is encountered, the counter update is never executed, causing the counter to not reflect the number of processed (non-null) records.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The continue statement is only valid inside a while loop.
Why it's wrong here
continue works in for, while, and do-while loops.
- ✗
The continue statement should be replaced with a break.
Why it's wrong here
break would exit the loop, not skip the iteration.
- ✓
The continue statement skips the rest of the loop body, including the counter update.
Why this is correct
continue causes the loop to proceed to the next iteration, skipping subsequent statements.
- ✗
The counter variable should be declared as volatile.
Why it's wrong here
volatile is not needed for single-threaded access.
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.