Difficulty: Easy
Correct Answer: Compiler will report an error in case ls > 20 as well as in case Else.
Explanation:
Introduction / Context:
This tests which constructs are valid inside a C# switch statement and how to specify a default branch.
Given Data / Assumptions:
Concept / Approach:
Case labels must be constant expressions of the same type as the switch expression. Relational expressions (like ls > 20) are not allowed. The default branch must be written as default:, not case Else: .
Step-by-Step Solution:
Verification / Alternative check:
Replace "case ls > 20:" with a proper if/else before the switch or compute a bucketed integer; replace "case Else:" with "default:".
Why Other Options Are Wrong:
Common Pitfalls:
Trying to embed boolean conditions in case labels and misusing Else instead of default.
Final Answer:
Compiler will report an error in case ls > 20 as well as in case Else.
Discussion & Comments