Question 7
Back to Exercise
Without any else, which is equivalent to if (a) { if (b) { work(); } }?
- A if (a || b) work();
- B if (a && b) work(); Correct
- C if (a) work(); if (b) work();
- D if (!a && !b) work();
Correct Answer: Option B
The inner block runs only when both conditions are true, and b is tested only when a is true – exactly the short-circuit behaviour of &&.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!