Multiple choice general knowledge science & technology

Suppose x=10 and y=10 what is x after evaluating the expression (y > 10) && (x++ > 10).

  1. 9

  2. 10

  3. 11

  4. false

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The answer is 10 because Java uses short-circuit evaluation for the && operator. Since y > 10 is false (y equals 10), the second condition (x++ > 10) is never evaluated, so the increment x++ doesn't execute. This means x remains 10. Option C (11) would only occur if the increment executed, and options A and D are nonsensical in this context.