Difficulty: Medium
Correct Answer: 2 1 0 def 1 def 1
Explanation:
Introduction / Context:
This problem tests how default behaves when reached (with or without a match) and how break truncates fall-through. You must trace four iterations of z and respect the textual order of cases.
Given Data / Assumptions:
Concept / Approach:
On a match, execution starts at that case and continues forward. If no case matches, execution starts at default and continues forward. The break after printing "1 " stops further fall-through for that iteration.
Step-by-Step Solution:
Verification / Alternative check:
Removing the break after case (x-1) would allow fall-through into case (x-2), changing the sequence.
Why Other Options Are Wrong:
Common Pitfalls:
Believing default executes only when no case matches; it also falls through to later cases unless a break stops it.
Final Answer:
2 1 0 def 1 def 1
Discussion & Comments