Boolean Operators: Quick Reference 🌶️
This page reviews the three boolean operators you'll use constantly in conditionals, then checks your understanding with a couple of quick questions.
The three operators:
A few things worth remembering:
| Operator | Meaning | True when |
|---|---|---|
&& | AND | both sides are true |
| || | OR | at least one side is true |
! | NOT | flips true to false, or false to true |
A few things worth remembering:
&&and||always take two operands;!takes exactly one.~also works as NOT in this course's tools, but in real Java~means something completely different (bitwise complement) — stick to!in your own code.- Short-circuit evaluation: in
a && b, ifais false,bis never even evaluated.
Common mistake: writingif (x = 5)instead ofif (x == 5). A single=is assignment, not comparison — and it compiles without error, which is exactly why it's dangerous.
1. Which expression is true when at least one of a or b is true, but not necessarily both?
Your score for your class is recorded when you click Submit all — checking individual questions doesn't save it. You can submit again to improve your score; your best one counts.