De Morgan's law is a rule for rewriting negated Boolean expressions in AP CSA: !(a && b) is equivalent to !a || !b, and !(a || b) is equivalent to !a && !b. When the ! distributes across parentheses, it flips each operand AND swaps && with || (EK 2.6.A.2).
De Morgan's law tells you how to push a negation inside parentheses in a Boolean expression. The rule has two halves. First, !(a && b) is equivalent to !a || !b. Second, !(a || b) is equivalent to !a && !b. The pattern is the same both times. Negate each piece, then swap the operator. The && becomes || and the || becomes &&.
The intuition is everyday logic. "It's NOT true that I have both homework AND practice" means "I'm missing homework OR I'm missing practice." If the combo fails, at least one piece failed. In Java, this also applies to relational operators when you simplify. For example, !(score < 0 || score > 100) becomes score >= 0 && score <= 100. Notice that negating score < 0 gives score >= 0, not score > 0. The negation of < is >=, because "not less than" includes equal.
De Morgan's law lives in Topic 2.6 (Equivalent Boolean Expressions) in Unit 2: Selection and Iteration. It directly supports learning objective AP Comp Sci A 2.6.A, comparing equivalent Boolean expressions, and it's named explicitly in EK 2.6.A.2. Two expressions are equivalent when they produce the same value in every case (EK 2.6.A.1), and De Morgan's law is your fastest tool for transforming one expression into another without building a full truth table. Beyond the exam, it's how you untangle messy negated conditions in if statements and loop conditions, which makes your selection and iteration code readable instead of a puzzle.
Keep studying AP® Computer Science A Unit 2
Truth tables (Unit 2)
Truth tables are the proof behind De Morgan's law. If you ever doubt an equivalence, list every combination of true/false for the variables and check that both expressions match in every row. De Morgan's law is the shortcut; truth tables are the receipts.
Object reference comparisons (Unit 2)
Topic 2.6 also covers comparing references with == and != and checking against null. You'll often combine these in compound conditions like !(obj == null || obj.equals(other)), and De Morgan's law lets you rewrite that as obj != null && !obj.equals(other).
Selection statements and loop conditions (Unit 2)
Most De Morgan's questions hide inside if statements and while loops. A loop that runs 'while not (done or error)' is the same as 'while not done and not error.' Rewriting exit conditions this way is the most common real use of the law in your own code.
De Morgan's law shows up almost exclusively in multiple choice. A typical stem gives you a negated compound expression like !(score < 0 || score > 100) and asks which expression could replace it, or hands you two expressions and asks whether they're equivalent for all values. Another common format prints the result of expressions like !(a && b) || c for specific boolean values. Your job is mechanical but precise. Distribute the !, flip each operand, swap the operator, and remember that negating relational operators flips them to their opposites (< becomes >=, > becomes <=). No released FRQ names De Morgan's law directly, but FRQs constantly require correct boolean conditions, and applying it wrong (forgetting to swap && and ||) produces logic bugs that cost points.
The classic trap is rewriting !(a && b) as !a && !b. That's wrong. De Morgan's law requires two moves, not one. You negate each operand AND you swap the operator, so !(a && b) becomes !a || !b. Try a = true, b = false to see why. !(true && false) is true, but !true && !false is false. One counterexample in a truth table proves they aren't equivalent.
De Morgan's law states that !(a && b) is equivalent to !a || !b, and !(a || b) is equivalent to !a && !b.
When you distribute a negation, you must do two things: negate each operand and swap && with ||.
Two Boolean expressions are equivalent only if they evaluate to the same value in every possible case, and a truth table can prove or disprove this.
Negating a relational operator flips it to its full opposite, so !(x < 5) becomes x >= 5, not x > 5.
The most common exam mistake is keeping the same operator after distributing the !, which a single truth-table row can expose as wrong.
Use De Morgan's law to simplify negated conditions in if statements and loops, like turning !(score < 0 || score > 100) into score >= 0 && score <= 100.
It's the rule in Topic 2.6 (EK 2.6.A.2) for rewriting negated Boolean expressions: !(a && b) is equivalent to !a || !b, and !(a || b) is equivalent to !a && !b. The negation moves inside and the operator flips.
No. !(a && b) equals !a || !b, with the operator swapped to ||. Test a = true, b = false: !(true && false) is true, but !true && !false is false, so they're not equivalent.
De Morgan's law is a transformation rule that rewrites an expression instantly, while a truth table is the proof method that checks every combination of values (EK 2.6.A.1). On the exam, apply De Morgan's law for speed and fall back on a truth table when you're unsure.
It's x >= 5, not x > 5. "Not less than 5" includes being equal to 5. Forgetting the equals case is one of the most common point-losers on equivalence MCQs.
Yes. It's named in the CED under learning objective AP Comp Sci A 2.6.A (EK 2.6.A.2) and shows up in multiple-choice questions asking you to find an equivalent expression or simplify a negated condition like !(score < 0 || score > 100).
Connect this key term to the AP exam workflow: review the course, practice questions, and check related study tools.
Review units, study guides, and course resources.
Check this vocabulary in multiple-choice context.
Apply key concepts in written AP responses.
Estimate the exam score you are working toward.
Review the highest-yield facts before practice.
Put the full course together before test day.