0
0
Kotlinprogramming~5 mins

Logical operators (&&, ||, !) in Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Atrue
Bfalse
Cnull
DCompilation error
Which operator returns true if at least one condition is true?
A||
B!
C==
D&&
What does the ! operator do to a boolean value?
ALeaves it unchanged
BConverts it to a number
CThrows an error
DReverses it (true to false, false to true)
What is the result of !(false && true)?
Anull
Bfalse
Ctrue
DCompilation error
Which of these expressions is true?
Atrue || false
Btrue && false
C!true
Dfalse || false
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.