Difficulty: Easy
Correct Answer: The if statement selects a statement for execution based on the value of a Boolean expression.
Explanation:
Introduction / Context:This question tests knowledge of how C# selection statements behave, particularly if/else and switch.
Given Data / Assumptions:
Concept / Approach:In C#, if evaluates a Boolean expression and selects a branch accordingly. switch requires unique case values and, unlike C, does not allow implicit fall-through between non-empty cases.
Step-by-Step Solution:
Option A: False — else-if chains are standard for multiple conditions.Option B: False — duplicate case values cause a compile error.Option C: Partially accurate but unnecessary nuance; the safe unequivocal truth is D.Option D: True — if chooses a path based on a Boolean expression.Option E: False — C# forbids implicit fall-through except into empty cases.Verification / Alternative check:Any C# specification summary confirms D; B and E are explicitly disallowed; A contradicts common usage.
Why Other Options Are Wrong:
Common Pitfalls:Confusing C# switch rules with C/C++ behavior.
Final Answer:The if statement selects a statement for execution based on the value of a Boolean expression.
Discussion & Comments