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:
No match for case 2 or case 4.Hit default: j += 2 → j = 2.Fall through to case 0: j += 4 → j = 6.End of switch; print "j = 6".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