Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Core Architecture, Basics & Control Flow

Q15: Consider the following statements regarding Logical and Bitwise operators in Java:

1. The short-circuit logical AND operator (&&) is optimized to evaluate the right-hand operand only if the left-hand operand successfully evaluates to true.
2. The bitwise AND operator (&) evaluates both the left and right operands comprehensively, regardless of whether the overall boolean outcome is already determined by the first operand.
3. Both the short-circuit (&&) and bitwise (&) logical operators can be utilized seamlessly to perform binary bit-level manipulation on standard integer numeric values.

Which of the above statements is/are correct?
A
Only 1 and 2
B
Only 2 and 3
C
Only 1 and 3
D
1, 2, and 3
✅ Correct Answer: A
🎯 Quick Answer:
The correct combination is 1 and 2. Statement 3 is incorrect because the short-circuit operator (&&) is strictly restricted to evaluating boolean expressions. It cannot be used for bit-level numerical manipulation; only the bitwise operator (&) can operate on binary integer structures.
Concept Definition: Logical operators compare boolean expressions to dictate program flow, while bitwise operators directly manipulate the individual 1s and 0s within integer variables.
Structural Breakdown: Java features two types of AND operators.
The logical short-circuit '&&' returns true only if both booleans are true.
The bitwise '&' performs a boolean AND if applied to booleans, but performs a binary mask operation if applied to integers (e.g., 5 & 3). Historical/Related Context: Short-circuit evaluation is a critical performance and safety feature inherited from C. It prevents unnecessary CPU cycles and prevents catastrophic runtime errors, such as a NullPointerException, when written in safe chains like: if (object \!= null && object.isActive()). Causal Reasoning: The bitwise '&' operator cannot short-circuit because bitwise manipulation mathematically requires comparing every single bit of both the left and right operands against each other to generate the final modified integer result.