Difficulty: Easy
Correct Answer: j = 6
Explanation:
Introduction / Context:
This MCQ reinforces switch fall-through semantics in Java when break statements are omitted. You must determine which labels execute when no case matches i=1 until default is reached.
Given Data / Assumptions:
Concept / Approach:
If no case matches, execution begins at default and proceeds downward until the switch block ends (fall-through). Therefore, default and all following case bodies execute sequentially.
Step-by-Step Solution:
Verification / Alternative check:
Add breaks after default or case 0 to change the result; with current code, both default and case 0 run.
Why Other Options Are Wrong:
Common Pitfalls:
Expecting that default stops execution; it does not without a break.
Final Answer:
j = 6
Discussion & Comments