Difficulty: Easy
Correct Answer: 1, 3
Explanation:
Introduction / Context:
The exercise assesses valid C# initialization forms when you want both variables i and j to be set to 10.
Given Data / Assumptions:
Concept / Approach:
Legal, clear initializations are either two separate statements or a compound declaration assigning both. The colon operator in (2) is invalid in this context. In (4) only j is initialized. In (5) chained assignment requires j to already exist in scope.
Step-by-Step Solution:
Verification / Alternative check:
Compile examples (1) and (3) — both succeed; (2), (4), (5) either fail or don’t meet the “both 10” requirement.
Why Other Options Are Wrong:
They include invalid constructs or statements that fail to set both variables to 10.
Common Pitfalls:
Believing chained assignment works inside the same declaration for multiple new identifiers.
Final Answer:
1, 3
Discussion & Comments