Every if statement, SQL WHERE clause and search query relies on Boolean logic. Master evaluating expressions and reading truth tables here.
| Operator | True when… |
|---|---|
| NOT A | A is FALSE |
| A AND B | Both A and B are TRUE |
| A OR B | At least one of A or B is TRUE |
Order of operations (without brackets): NOT first, then AND, then OR — but always use brackets in exam answers to make your intended order explicit.
Work outward from the innermost brackets, one operator at a time — never try to evaluate a whole expression in one leap.
(A AND B) OR C where A=TRUE, B=TRUE, C=FALSE Step 1: (A AND B) → (TRUE AND TRUE) → TRUE Step 2: TRUE OR C → TRUE OR FALSE → TRUE
Pick an expression below to see every possible combination of its variables and the resulting output — this is exactly how you'd build a truth table by hand in the exam.
Pick an expression to generate its full truth table:
| A | B | A AND B |
|---|---|---|
| F | F | F |
| F | T | F |
| T | F | F |
| T | T | T |
Question 1
Given A = TRUE, B = FALSE, what is the result of (A AND B)?
Question 2
Given A = TRUE, B = FALSE, what is the result of (A OR B)?
Question 3
What is NOT(TRUE)?
Question 4
Evaluate (A AND B) OR C, given A = TRUE, B = TRUE, C = FALSE.
(A AND B) OR C
Question 5
Evaluate (A AND B) OR C, given A = FALSE, B = TRUE, C = FALSE.
(A AND B) OR C
Question 6
A learner qualifies for an award if: age is 16 or older, AND (has an A average OR is a prefect). age = 17, average = 'B', isPrefect = TRUE. Does the learner qualify?
age >= 16 AND (average == 'A' OR isPrefect)
Question 7
Which relational operator would you use in code to check that a value is 'not equal to' another in Java?
Question 8
In a search engine, which Boolean search would return results containing 'python' but excluding results about the reptile?
Question 9
Complete this row of a truth table for the expression (A OR B) AND NOT C, given A = FALSE, B = FALSE, C = FALSE.
(A OR B) AND NOT C
Question 10
What determines the order in which a Boolean expression without brackets is evaluated?
Question 11
How many rows does a complete truth table need for a Boolean expression with 3 distinct variables?
Question 12
Evaluate NOT(A AND B), given A = TRUE, B = TRUE.
NOT(A AND B)
Question 13
A discount applies if: totalSpend >= 500 OR isMember is TRUE, AND it is NOT a public holiday. totalSpend = 300, isMember = TRUE, isPublicHoliday = FALSE. Does the discount apply?
(totalSpend >= 500 OR isMember) AND NOT isPublicHoliday
Question 14
Evaluate A OR (B AND C), given A = FALSE, B = TRUE, C = FALSE.
A OR (B AND C)
Question 15
Which Java operator checks that BOTH of two boolean conditions are true, short-circuiting (skipping the second check) if the first is already false?
Question 16
A login is allowed if: username matches AND (password matches OR hasValidToken). username matches = TRUE, password matches = FALSE, hasValidToken = TRUE. Is login allowed?
usernameMatches AND (passwordMatches OR hasValidToken)
Question 17
According to De Morgan's Law, NOT(A AND B) is logically equivalent to which expression?