1Z0-829 Controlling Program Flow Practice Question
Which three of the following statements about the switch expression in Java 17 are correct?
⚠ Common exam trap
Watch out — candidates often confuse the requirement for a default branch in switch expressions with the behavior of switch statements, mistakenly thinking a default is always mandatory even when all cases are covered.
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
✓
A switch expression with arrow syntax does not require break.
In a switch expression with arrow syntax (->), each branch is a single expression or block that is automatically terminated, eliminating the need for a break statement. The arrow syntax implicitly prevents fall-through, making the code more concise and less error-prone.
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 switch expression with arrow syntax does not require break.
Why this is correct
Arrow syntax implicitly prevents fall-through, so break is unnecessary.
- ✓
A switch expression with colon syntax can use yield to return a value.
Why this is correct
In colon syntax, yield is used to provide a value for the expression.
- ✗
A switch expression cannot be used with an enum type.
Why it's wrong here
Switch expressions can be used with enum types.
- ✗
A switch expression must include a default branch even if all cases are covered.
Why it's wrong here
If all cases are covered exhaustively, a default branch is optional.
- ✓
A switch expression must be exhaustive.
Why this is correct
Switch expressions must cover all possible values or have a default branch.
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.