Difficulty: Medium
Correct Answer: 0
Explanation:
Introduction / Context:
This question checks precedence of bitwise operators, arithmetic evaluation, and the effect of Convert.ToBoolean on integer values in C#.
Given Data / Assumptions:
Concept / Approach:
Operator precedence: & (bitwise AND) binds tighter than | (bitwise OR). Arithmetic executes before bitwise. Convert.ToBoolean(x) is true for any nonzero integer and false for zero.
Step-by-Step Solution:
Verification / Alternative check:
You can reason by bit positions: value 2 has only the 2's bit set; -23 ends with ...1001 (for -23 it is 1111...1110 1001), making the 2's bit 0; their AND is 0.
Why Other Options Are Wrong:
Common Pitfalls:
Mixing up logical && with bitwise &, and assuming negative & positive is always nonzero. It depends on overlapping set bits.
Final Answer:
0
Discussion & Comments