Courseiva
Question 361 of 513
Controlling Program FloweasyMultiple ChoiceObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Exhibit

Refer to the exhibit.
$ cat Test.java
public class Test {
    public static void main(String[] args) {
        String s = "Hello";
        switch (s) {
            case "Hello": System.out.print("1");
            case "World": System.out.print("2");
            default: System.out.print("3");
        }
    }
}
$ java Test

What is the output?

⚠ Common exam trap

The trap is that candidates often forget that switch cases fall through to subsequent cases unless a break statement is used, leading them to think only '1' is printed.

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

123

123. This output results from a switch statement with fall-through behavior. The matching case prints '1', but because there is no break, execution continues to the next case printing '2', and then to the next printing '3' until a break is encountered or the switch ends. Thus, '123' is printed.

Answer analysis

Option-by-option breakdown

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

  • 13

    Why it's wrong here

    Incorrect; case "World" also executes.

  • 123

    Why this is correct

    Correct: prints all three due to fall-through.

  • 12

    Why it's wrong here

    Incorrect; it falls through to default as well.

  • 1

    Why it's wrong here

    Incorrect; fall-through occurs.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 25, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.