1Z0-829 enum ordinal Practice Question
Exhibit
enum Day { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY }
int numLetters = switch (day) {
case MONDAY, FRIDAY, SUNDAY -> 6;
case TUESDAY -> 7;
default -> { int len = day.name().length(); yield len; }
};
System.out.println(numLetters);Refer to the exhibit. The exhibit shows a code snippet. What is the output when the variable day is set to Day.WEDNESDAY?
⚠ Common exam trap
The trap here is that candidates forget that switch cases fall through by default if break statements are missing, and they often overlook the effect of a default case that executes after fall-through, leading them to miscalculate the total.
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
✓
9
(9) because the switch statement on Day.WEDNESDAY (ordinal 2) does not have break statements for cases WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY, causing fall-through. Execution adds values: WEDNESDAY (3), THURSDAY (4), FRIDAY (5), SATURDAY (6), totaling 18. Then the default case subtracts 9, resulting in 9.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
7
Why it's wrong here
7 corresponds to TUESDAY, not WEDNESDAY.
- ✗
Compilation error
Why it's wrong here
The code compiles successfully.
- ✗
6
Why it's wrong here
6 corresponds to MONDAY, FRIDAY, or SUNDAY, not WEDNESDAY.
- ✓
9
Why this is correct
The default branch yields the length of "WEDNESDAY", which is 9.
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.