What this quiz covers
This quiz focuses on Compound Boolean Expressions, giving you a quick way to practice the rules, question types, and explanations that matter most for AP Computer Science a.
Consider the expression: !(a || b) && (c && !d). This expression is logically equivalent to which of the following?
AP Computer Science a Quiz
Practice Compound Boolean Expressions in AP Computer Science a with focused quiz questions that help you check what you know, review explanations, and build confidence with test-style prompts.
This quiz focuses on Compound Boolean Expressions, giving you a quick way to practice the rules, question types, and explanations that matter most for AP Computer Science a.
Try each quiz question before looking at the correct answer. Use the explanations to review missed ideas, then come back to similar questions until the pattern feels familiar.
Consider the expression: !(a || b) && (c && !d). This expression is logically equivalent to which of the following?
!(a || b) && (c && !d) step by step. First, apply De Morgan's Law to the first part: !(a || b) becomes (!a && !b). The second part (c && !d) remains unchanged since there's no negation affecting the entire expression.
So our expression becomes: (!a && !b) && (c && !d). This matches answer choice D exactly.
Let's examine why the other options are incorrect:
Choice A (!a && !b) || (c && !d) changes the main logical operator from AND (&&) to OR (||), which completely alters the truth conditions of the expression.
Choice B (!a || !b) && (c || !d) makes two errors: it incorrectly applies De Morgan's Law to get (!a || !b) instead of (!a && !b), and it changes (c && !d) to (c || !d).
Choice C !(a && b) && (!c || d) incorrectly leaves the first part as !(a && b) without applying De Morgan's Law, and completely reverses the second part by negating both c and d while changing AND to OR.
Study tip: Master De Morgan's Laws: !(A || B) = (!A && !B) and !(A && B) = (!A || !B). Practice by writing out truth tables when you're unsure—this will help you verify logical equivalences quickly on the exam.Consider the following compound Boolean expression: (x > 5 && y < 10) || (x <= 5 && y >= 10). For which of the following pairs of values would this expression evaluate to false?
Given the expression !(a && b) && (c || !d), when will this expression evaluate to true? Assume all variables are boolean.
A method contains the condition: (score >= 90 && attempts <= 3) || (score >= 80 && bonus). If score = 85, attempts = 2, and bonus = false, what changes would make this expression evaluate to true?
&&) and OR (||) operators, break them down systematically by evaluating each part separately. This expression has two main parts connected by OR: (score >= 90 && attempts <= 3) OR (score >= 80 && bonus).
With the given values (score = 85, attempts = 2, bonus = false), let's evaluate each part. The first part (score >= 90 && attempts <= 3) becomes (85 >= 90 && 2 <= 3), which is (false && true) = false. The second part (score >= 80 && bonus) becomes (85 >= 80 && false), which is (true && false) = false. Since both parts are false, the entire expression is false OR false = false.
To make this true, you need at least one part to become true. Looking at option D, changing score to 90 makes the first part (90 >= 90 && 2 <= 3) = true, or changing bonus to true makes the second part (85 >= 80 && true) = true. Either change works.
Option A is wrong because changing attempts to 4 makes the first part false (4 > 3), though changing bonus to true would work. Option B fails because changing score to 75 makes both parts false (75 < 90 and doesn't help the second part), and changing attempts to 1 doesn't fix the score issue in the first part. Option C requires both changes together, but the question asks what changes would work, and either change in D works independently.
Remember: with OR expressions, you only need one side to be true, so look for changes that make at least one complete side evaluate to true.A game awards bonus points when: (level > 5 && enemies == 0) || (level <= 5 && timeLeft > 60). A player is at level 3 with 45 seconds left and no enemies remaining. To earn bonus points, what is the minimum change needed?
(level > 5 && enemies == 0) || (level <= 5 && timeLeft > 60).
Let's evaluate the current situation: level 3, timeLeft 45, enemies 0. For the first condition (level > 5 && enemies == 0): level 3 is not greater than 5, so this entire AND expression is false regardless of enemies being 0. For the second condition (level <= 5 && timeLeft > 60): level 3 is less than or equal to 5 (true), but timeLeft 45 is not greater than 60 (false), making this AND expression false. Since both parts of the OR are false, no bonus points are awarded.
To earn bonus points, you need to make at least one part true. The minimum change is increasing timeLeft to at least 61, which makes the second condition (level <= 5 && timeLeft > 60) evaluate to true.
Answer A is incorrect because it suggests either change works independently, but increasing level to 6 alone wouldn't help since enemies would need to be 0 AND level > 5. Answer B incorrectly focuses only on the first condition. Answer D makes the same error as A, suggesting level 6 alone would work.
Strategy tip: In OR expressions, you only need ONE part to be true. Always check which condition requires the fewest changes to become true, especially when dealing with multiple AND conditions within an OR statement.Given three boolean variables p, q, and r, the expression (p && q) || (p && r) || (q && r) represents which logical condition?
A program needs to check if a student is eligible for a scholarship. The conditions are: GPA must be at least 3.5 AND (either community service hours >= 100 OR leadership position is true). Which compound Boolean expression correctly represents these conditions?
Consider the compound condition: (x % 2 == 0 && x > 0) || (x % 3 == 0 && x < 0). For which value of x would this expression be false?
(x % 2 == 0 && x > 0) || (x % 3 == 0 && x < 0). The entire expression is true if either the left side OR the right side (or both) evaluates to true. For it to be false, both sides must be false.
Let's test each option:
For choice A (x = -6): The left side is false because -6 is even but not positive. The right side is true because -6 is divisible by 3 and negative. Since one side is true, the entire expression is true.
For choice B (x = 8): The left side is true because 8 is even and positive. Since one side is true, the entire expression is true.
For choice D (x = 0): The left side is false because 0 is even but not positive. The right side is false because while 0 is divisible by 3, it's not negative. However, this creates ambiguity since 0 is neither positive nor negative.
For choice C (x = 5): The left side is false because 5 is odd (not even). The right side is false because 5 is not divisible by 3. Since both sides are false, the entire expression is false.
Therefore, C is correct.
Strategy tip: With compound conditions, systematically evaluate each subexpression and use a truth table approach. Remember that OR expressions are false only when all parts are false, while AND expressions are true only when all parts are true.A program validates user input with: (age >= 18 && age <= 65) && (income > 30000 || hasGuarantor). If this expression evaluates to false, which of the following must be true?
A security system uses the condition: !((status.equals("armed") && motion) || (status.equals("test") && !authorized)). Under which circumstances will this expression evaluate to true?