Courseiva
Controlling Program FlowhardMultiple ChoiceObjective-mapped

1Z0-829 Labeled continue statement Practice Question

A financial trading system uses a Java application to process market data. The core algorithm uses nested loops to compare price arrays. The developer uses a labeled continue statement to skip certain combinations. After a code review, the team suspects the algorithm has a bug that causes incorrect results. The developer writes a unit test and discovers that the labeled continue sometimes skips more iterations than intended. The code is: outer: for (int i = 0; i < prices1.length; i++) { for (int j = 0; j < prices2.length; j++) { if (prices1[i] < prices2[j]) continue outer; // process combination } } The developer intended that if any price in prices1 is less than a price in prices2, the entire row (i) should be skipped. However, the algorithm skips rows even when the condition is not met for all j. What is the most likely cause?

⚠ Common exam trap

The trap is that candidates may think a labeled continue always affects a loop outside the current one, but in Java the label identifies which loop to continue. Placing the label on the inner loop means the continue targets that inner loop, not the outer loop. This leads to unexpected behavior where only a single inner iteration is skipped instead of the entire outer row.

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 condition for continuing is not correctly evaluated.

The developer intended to skip the i-th row only if for every j, prices1[i] < prices2[j]. However, the condition currently uses an inequality that triggers on any j, causing rows to be skipped prematurely. The bug is that the condition is not correctly evaluating the intended logic; it should check that the condition holds for all j, not just one. Therefore, the correct answer is 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.

  • A break statement is missing after processing a combination.

    Why it's wrong here

    Incorrect. A missing break statement would not cause the described behavior; the issue is with the condition logic.

  • The label outer is placed on the inner loop, not the outer loop.

    Why it's wrong here

    Incorrect. In the given code, the label 'outer' is correctly placed on the outer loop, so this is not the cause of the bug.

  • The condition for continuing is not correctly evaluated.

    Why this is correct

    Correct. The condition checks for any j, but the intent was to skip only when the condition holds for all j. Thus the condition is not correctly evaluated.

  • The continue outer statement should be a break outer.

    Why it's wrong here

    Incorrect. Using break outer would terminate the outer loop entirely, which is not the intended behavior.

About these practice questions

One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.