1Z0-829 Controlling Program Flow Practice Question
Which TWO statements about the switch statement in Java are true?
⚠ Common exam trap
It's easy for candidates to assume break is mandatory in all switch constructs, or they mistakenly think long is a valid switch type because it is a numeric primitive, but Java explicitly excludes long from switch expressions.
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 break statement is optional.
In a Java switch statement, the break statement is optional. If omitted, execution falls through to the next case (fall-through behavior), which can be intentional or lead to bugs. This is a core feature of the switch construct, not a requirement.
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 optional.
Why this is correct
Without break, execution falls through to the next case.
- ✗
A switch statement can be used as an expression in all cases.
Why it's wrong here
Switch expressions (with ->) can assign a value, but traditional switch with colon cannot.
- ✗
The switch expression can be of type long.
Why it's wrong here
long is not allowed; switch supports byte, short, char, int, String, and enum types.
- ✓
The switch expression can be of type String.
Why this is correct
String is allowed as a switch expression since Java 7.
- ✗
The case values can be variables.
Why it's wrong here
Case values must be compile-time constants (literals or final variables initialized with constants).
Go deeper
Related to this question
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 →
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.