Truth tables in AP Computer Science A

A truth table is a systematic chart listing every possible combination of true/false values for the variables in a Boolean expression along with the expression's result. In AP CSA (EK 2.6.A.1), two expressions are equivalent if their truth tables match in every row.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is truth tables?

A truth table is a brute-force proof tool. You list every possible true/false combination of your Boolean variables in rows, then evaluate the expression for each row. With one variable you need 2 rows, with two variables 4 rows, with three variables 8 rows. The pattern is 2^n rows for n variables, because each variable doubles the possibilities.

The reason truth tables exist in the AP CSA course is equivalence. EK 2.6.A.1 says two Boolean expressions are equivalent if they evaluate to the same value in all cases, and a truth table is exactly how you check "all cases" without guessing. Build a table for !(a && b), build one for !a || !b, and you'll see the output columns match on every row. That match is the proof, and it's also a demonstration of De Morgan's law. Think of a truth table as the receipts behind any claim that two pieces of Boolean logic do the same thing.

Why truth tables matters in AP® Computer Science A

Truth tables live in Unit 2 (Selection and Iteration), Topic 2.6: Equivalent Boolean Expressions, supporting learning objective 2.6.A (compare equivalent Boolean expressions). They matter because the exam loves to show you a Boolean condition written one way and ask which answer choice means the same thing. Spotting that !(x > 5) is the same as x <= 5, or that !(a || b) is the same as !a && !b, is a pure equivalence skill. The truth table is the method that makes those answers checkable instead of vibes-based. The same skill carries through the rest of Unit 2, since every if statement and while loop condition you write is a Boolean expression you might need to simplify or rewrite.

How truth tables connects across the course

De Morgan's law (Unit 2)

De Morgan's law (EK 2.6.A.2) tells you that !(a && b) equals !a || !b and !(a || b) equals !a && !b. A truth table is how you prove that claim. De Morgan's is the shortcut, the truth table is the receipt.

Object reference comparison (Unit 2)

Topic 2.6 also covers comparing references with ==, !=, and equals (LO 2.6.B). These comparisons produce Boolean values too, so the same equivalence thinking applies. The expression ref != null is just another Boolean you can reason about in all cases.

Conditional statements and loops (Unit 2)

Every if, else if, and while runs on a Boolean condition. When you simplify a messy condition like !(score >= 60) into score < 60, you're doing equivalence work that a truth table could verify. Cleaner conditions mean fewer logic bugs in FRQ code.

Is truth tables on the AP® Computer Science A exam?

You won't be handed a blank truth table to fill in on the AP exam. Instead, multiple-choice questions test the skill a truth table represents. A typical stem shows a Boolean expression, often a negated compound condition like !(x < 3 || y == 7), and asks which answer choice is equivalent. The fast path is De Morgan's law; the safe path when you're unsure is mentally checking a few true/false combinations, which is a mini truth table in your head. Watch for trap answers that match the original expression in some cases but not all, because equivalence requires matching in every case (EK 2.6.A.1). No released FRQ asks for a truth table by name, but writing correct, simplified conditions in your FRQ code is where this skill quietly earns points.

Truth tables vs De Morgan's law

These two get blurred because they show up in the same topic. De Morgan's law is a rule for rewriting expressions (distribute the ! and flip &&/||). A truth table is a method for verifying that any rewrite, De Morgan's or otherwise, is actually equivalent. De Morgan's gives you the answer fast; the truth table proves the answer is right.

Key things to remember about truth tables

  • Two Boolean expressions are equivalent only if they produce the same result in every possible case, and a truth table checks every case by listing them all.

  • A truth table needs 2^n rows for n Boolean variables, so two variables means 4 rows and three variables means 8 rows.

  • If the output columns of two truth tables match on every single row, the expressions are equivalent; if they differ in even one row, they are not.

  • Truth tables are the proof behind De Morgan's law, which says !(a && b) equals !a || !b and !(a || b) equals !a && !b.

  • On the exam, equivalence questions are usually multiple choice, and testing a couple of true/false combinations in your head can eliminate wrong answers quickly.

Frequently asked questions about truth tables

What is a truth table in AP Computer Science A?

It's a table that lists every possible true/false combination of the variables in a Boolean expression and the expression's result for each combination. In Topic 2.6, it's the tool for proving two Boolean expressions are equivalent (EK 2.6.A.1).

Do I have to draw truth tables on the AP CSA exam?

No. The exam never asks you to fill in a truth table directly. It tests the underlying skill, usually with multiple-choice questions asking which expression is equivalent to a given one, like recognizing that !(a || b) means !a && !b.

What's the difference between a truth table and De Morgan's law?

De Morgan's law is a rewriting rule (negate each part and swap && with ||), while a truth table is a verification method that checks all cases. You'd use De Morgan's to transform an expression and a truth table to prove the transformation is correct.

How do you use a truth table to prove two Boolean expressions are equivalent?

Build a table with one row for every combination of variable values (4 rows for two variables, 8 for three), evaluate both expressions in each row, and compare the output columns. If they match on all rows, the expressions are equivalent; one mismatch means they're not.

How many rows does a truth table have?

2^n rows, where n is the number of Boolean variables. Each variable can be true or false, so every new variable doubles the number of combinations you have to check.