Courseiva
Controlling Program FlowmediumMultiple ChoiceObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Given nested loops with labels, which statement correctly breaks out of the outer loop?

⚠ Common exam trap

The trap here is that candidates often forget that a plain 'break' only exits the innermost loop, and they may incorrectly assume 'continue outer;' or 'return;' achieve the same effect as a labeled break, leading them to choose a wrong option.

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

break outer;

The labeled break statement 'break outer;' terminates the outer loop when executed inside the inner loop. In Java, a label (e.g., 'outer:') placed before a loop allows a break or continue to target that specific loop, overriding the default behavior of breaking only the innermost loop. The other options do not break out of the outer loop: 'continue outer;' would skip the current iteration of the outer loop but not break it, 'return;' would exit the method entirely, and 'break inner;' would break the inner loop but not the outer.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • break outer;

    Why this is correct

    This labeled break exits the loop labeled 'outer'.

  • continue outer;

    Why it's wrong here

    This continues the outer loop's next iteration, does not exit.

  • return;

    Why it's wrong here

    Return exits the entire method, not just the outer loop.

  • break inner;

    Why it's wrong here

    This would break the inner loop, not the outer.

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 →

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.