Comparing Boolean Expressions - AP Computer Science A
- Which expression is equivalent to !(a || b)?
- !a && !b. De Morgan's Law: negate OR, flip to AND, negate operands.
- What is the result of the expression: !true?
- false. NOT operator flips true to false.
- Determine the result of: true && (false || true).
- true. Parentheses first: (false || true) is true, then true && true.
- Which expression is equivalent to !(a && b)?
- !a || !b. De Morgan's Law: negate AND, flip to OR, negate operands.
- Evaluate: (false && false) || (true && false).
- false. Both AND operations are false, so false OR false is false.
- Determine the result of: true || (false && true).
- true. true OR anything is always true.
- What is the result of the expression: true || false?
- true. OR returns true if at least one operand is true.
- Evaluate: true && (!false || false).
- true!false is true, (true || false) is true, true && true is true.
- What does the '!' operator do in a Boolean expression?
- Negates the Boolean value. The NOT operator flips true to false and vice versa.
- Determine the result of: (true || false) && !false.
- true. (true || false) is true, and true && true is true.
- What is the precedence order of the operators: &&, ||, ! ?
- !, &&, ||. NOT has highest precedence, then AND, then OR.
- Determine the result of: !(false || (true && true)).
- false. (true && true) is true, (false || true) is true, !(true) is false.
- Determine the result of: (true || false) && false.
- false. (true || false) is true, but true && false is false.
- What is the result of the expression: !false?
- true. NOT operator flips false to true.
- Determine the result of: !(true && (false || true)).
- false. Inner expression is true, so !(true) is false.
- Evaluate: !(false && (true || false)).
- true. (false && anything) is false, so !(false) is true.
- Evaluate the expression: false || !true.
- false. false OR !true becomes false OR false equals false.
- What is the result of: (true && true) || false?
- true. (true && true) is true, and true OR false is true.
- What Boolean operator is represented by '&&'?
- Logical AND. Returns true only when both operands are true.
- What is the result of the expression: true && false?
- false. AND requires both operands to be true.
- Evaluate: true || (!false && false).
- true. true OR anything is always true.
- Determine the result of: (true && false) || true.
- true. (true && false) is false, but false || true is true.
- What Boolean operator is represented by '||'?
- Logical OR. Returns true when at least one operand is true.
- Evaluate: false && (!false || true).
- false. false AND anything is always false.