Comparing Boolean Expressions FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Complete the table for !(p && q) and !p || !q. Then state whether the two expressions are equivalent and why.

p q !(p && q) !p || !q
false false
false true
true false
true true

Question 2 of 5

A greenhouse alarm uses !(humid || dark).

(a) Rewrite the expression using De Morgan's law so that ! is applied only to humid and dark individually. (b) Evaluate the original expression when humid is false and dark is true. (c) Evaluate your rewritten expression with the same values and confirm they match.

Question 3 of 5

A student claims that a || (b && c) is equivalent to (a || b) && c for all booleans.

(a) Evaluate both expressions when a is true, b is false, and c is false. (b) State whether the expressions are equivalent. (c) If they are not equivalent, explain how the counterexample shows they differ. If they are equivalent, justify with a brief truth-table argument.

Question 4 of 5

A Ticket stores a seat code. Ticket.equals returns true when both objects are non-null Tickets whose seat codes are equal according to String.equals.

Ticket p = new Ticket("A1");
Ticket q = new Ticket("A1");
Ticket r = p;
Ticket s = null;

(a) State the value of p == q and explain it in terms of references. (b) State the value of p.equals(q) using the given contract. (c) State the value of p == r. (d) Explain why evaluating s.equals(p) is unsafe.

Question 5 of 5

A concert kiosk stores an optional badge tag.

String tag = null;

(a) Write a boolean expression that is true only when tag is not null and represents the characters VIP, and that does not throw when tag is null. (b) Explain why tag.equals("VIP") throws for this tag. (c) Explain why tag != null && tag.equals("VIP") does not throw.