Question 1 of 5
Complete the table for !(p || q) and !p && !q. Then state whether the two expressions are equivalent.
| p | q | !(p || q) | !p && !q |
|---|---|---|---|
| false | false | ||
| false | true | ||
| true | false | ||
| true | true |
Responses receive AI feedback against a rubric after submission. Scores are practice estimates.
Complete the table for !(p || q) and !p && !q. Then state whether the two expressions are equivalent.
| p | q | !(p || q) | !p && !q |
|---|---|---|---|
| false | false | ||
| false | true | ||
| true | false | ||
| true | true |
A road sensor uses !(speed > 50 && wet).
(a) Rewrite the expression using De Morgan's law, with ! applied to each original operand. (b) Evaluate the original when speed is 60 and wet is true. (c) Evaluate your rewrite with the same values.
Show that ! (a && !b) is equivalent to !a || b.
(a) Complete a four-row truth table with columns a, b, !(a && !b), and !a || b. (b) State whether the last two columns match in every row. (c) Briefly connect the table to De Morgan's law.
Three String variables refer to bay labels.
String u = new String("bay");
String v = new String("bay");
String w = u;
(a) State the value of u == v. (b) State the value of u.equals(v). (c) State the value of u == w and explain the difference between == and equals for these objects.
A Pass stores a color code. Pass.equals returns true when both objects are non-null Pass objects whose codes are equal according to String.equals.
Pass p = new Pass("RED");
Pass q = new Pass("RED");
Pass r = p;
Pass z = null;
(a) Compare p == q with p.equals(q). (b) Compare p == r with p.equals(r). (c) Write a boolean expression that is true only when z is a non-null Pass whose code is RED, and that does not throw when z is null. (d) Explain why z.equals(p) is unsafe.