Given: boolean a = false; boolean b = true; boolean c = true; System.out.println(a || b && c); What is the output?
Correct due to operator precedence.
Why this answer
In Java, the logical AND operator (&&) has higher precedence than the logical OR operator (||). Therefore, the expression `a || b && c` is evaluated as `a || (b && c)`. Given `a = false`, `b = true`, and `c = true`, `b && c` evaluates to `true`, and then `false || true` evaluates to `true`.
Thus, the output is `true`, making option D correct.
Exam trap
The trap here is that candidates often evaluate the expression left-to-right without considering operator precedence, mistakenly thinking `a || b` is evaluated first (which would be `true`) and then `&& c` would produce `true && true` = `true`, but the actual precedence changes the grouping, though in this specific case both orders yield `true`; however, the trap is to test whether you know the precedence rule, not just the outcome.
How to eliminate wrong answers
Option A is wrong because it assumes the expression evaluates to `false`, which would only happen if both sides of the `||` were false, but `b && c` is true. Option B is wrong because the code compiles successfully; all variables are declared with valid boolean literals and the operators are correctly applied. Option C is wrong because 'None of the above' is not correct since option D provides the accurate output.