1Z0-811 Primitives, Strings and Operators Practice Question
A developer writes: boolean b = !true && false; What is the value of b?
⚠ Common exam trap
The trap here is that candidates may misinterpret the precedence and think `!true && false` is evaluated as `!(true && false)` (which would be `true`), but in Java, the logical NOT (`!`) has higher precedence than logical AND (`&&`), so `!true` is evaluated first.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
false
The expression `!true && false` is evaluated as `(!true) && false`, which is `false && false`. The logical AND (`&&`) operator returns `true` only if both operands are `true`; otherwise, it returns `false`. Therefore, `b` is assigned `false`. Option B is correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Compilation error: invalid operator.
Why it's wrong here
Valid boolean expression.
- ✓
false
Why this is correct
!true -> false; false && false -> false.
- ✗
NullPointerException
Why it's wrong here
No objects involved.
- ✗
true
Why it's wrong here
Both operands are false.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.