Recall & Review
beginner
What does the logical AND operator (&&) do in Kotlin?
The logical AND operator (&&) returns true only if both conditions on its sides are true. If either condition is false, it returns false.
Click to reveal answer
beginner
Explain the logical OR operator (||) in Kotlin.
The logical OR operator (||) returns true if at least one of the conditions is true. It returns false only if both conditions are false.
Click to reveal answer
beginner
What is the purpose of the logical NOT operator (!) in Kotlin?
The logical NOT operator (!) reverses the value of a boolean expression. If the expression is true, ! makes it false, and vice versa.
Click to reveal answer
beginner
Given: val a = true, val b = false, what is the result of a && b?
The result is false because the AND operator requires both sides to be true, but b is false.
Click to reveal answer
intermediate
How does Kotlin evaluate the expression: !(true || false)?
First, true || false evaluates to true. Then, !true becomes false. So the whole expression is false.
Click to reveal answer
What is the result of true && false in Kotlin?
✗ Incorrect
The AND operator returns true only if both sides are true. Here, one side is false, so the result is false.
Which operator returns true if at least one condition is true?
✗ Incorrect
The OR operator (||) returns true if any one of the conditions is true.
What does the ! operator do to a boolean value?
✗ Incorrect
The NOT operator (!) reverses the boolean value.
What is the result of !(false && true)?
✗ Incorrect
false && true is false, then !false is true.
Which of these expressions is true?
✗ Incorrect
true || false is true because OR returns true if any side is true.
Describe how the logical AND (&&) and OR (||) operators work in Kotlin with simple examples.
Think about when you want both conditions to be true versus when one is enough.
You got /3 concepts.
Explain the effect of the logical NOT operator (!) on a boolean expression.
It flips the meaning of a condition.
You got /3 concepts.