Difficulty: Easy
Correct Answer: Compilation fails.
Explanation:
Introduction / Context:
This question mixes switch fall-through with an intentional typographical error in a case label to ensure you can spot invalid identifiers in constant labels.
Given Data / Assumptions:
case l:
using the letter l
(ell), not the digit 1
.
Concept / Approach:l
is an undefined identifier and not a constant integer literal. Therefore, the switch statement contains an invalid case label, causing compilation to fail before any runtime behavior is possible.
Step-by-Step Solution:
Type-check case labels: l
is not a valid constant expression.The compiler reports an error for the first case and stops.No output is produced.
Verification / Alternative check:
Change case l:
to case 1:
and re-run; then evaluate fall-through to compute the final value.
Why Other Options Are Wrong:
They all assume successful compilation and a numeric result.
Common Pitfalls:
Misreading the letter l
as the digit 1
.
Final Answer:
Compilation fails.
Discussion & Comments