Difficulty: Easy
Correct Answer: 1, 4, 5
Explanation:
Introduction / Context:
This tests understanding of the logical AND operator && in C#, including short-circuit evaluation and the exact condition needed for assignment to execute.
Given Data / Assumptions:
Concept / Approach:
In C#, && is a short-circuiting operator. The right-hand condition is evaluated only if the left-hand condition is true. The if body executes only if both subconditions evaluate to true.
Step-by-Step Solution:
Verification / Alternative check:
Truth table for && confirms that the right operand evaluates only when the left operand is true and the overall result is true only when both are true.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing && with ||, or assuming both sides always evaluate. With &&, the second operand can be skipped.
Final Answer:
1, 4, 5
Discussion & Comments