Courseiva
Controlling Program FlowmediumMultiple SelectObjective-mapped

1Z0-829 Controlling Program Flow Practice Question

Which THREE statements about the switch statement in Java are correct?

⚠ Common exam trap

Many exam-takers assume the default case must be last, or that break is always required, or that any final variable can be used as a case label, when in fact only compile-time constant expressions are allowed.

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 default case can be placed anywhere within the switch block.

The default case can be placed anywhere within the switch block according to the Java Language Specification. Option D is correct: case labels must be compile-time constant expressions; a final variable assigned a constant expression qualifies as a compile-time constant. Option E is correct: switch works with int, char, String, and enum types. Option B is incorrect because case values must be compile-time constants, not arbitrary runtime expressions. Option C is incorrect because break is not mandatory; it is optional and used to prevent fall-through.

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 default case can be placed anywhere within the switch block.

    Why this is correct

    Correct. The default case can appear anywhere in the switch block.

  • Case values can be runtime expressions.

    Why it's wrong here

    Incorrect. Case values must be compile-time constant expressions.

  • A break statement is mandatory after each case block.

    Why it's wrong here

    Incorrect. break is optional; without it, execution falls through to the next case.

  • Case labels can be variables if they are final and assigned a constant expression.

    Why this is correct

    Correct. A final variable initialized with a constant expression is a compile-time constant.

  • The switch statement can be used with int, char, String, and enum types.

    Why this is correct

    Correct. switch supports int, char, String, and enum types.

About these practice questions

This 1Z0-829 question is part of Courseiva's 513-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.