Which of the following statements is correct regarding C# selection statements?

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:

  • We evaluate five independent statements and must pick one correct statement.


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:

  • A: else-if is the normal extension.
  • B: Duplicate case values are illegal.
  • C: Even the last default block typically uses break or returns; D is the clearly correct general statement.
  • E: No implicit fall-through in non-empty cases.


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.

More Questions from Control Instructions

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion