0
0
Kotlinprogramming~20 mins

Logical operators (&&, ||, !) in Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Logical Operator Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Kotlin code using logical AND (&&)?
Consider the following Kotlin code snippet. What will it print?
Kotlin
fun main() {
    val a = true
    val b = false
    println(a && b)
}
Atrue
BRuntime exception
CCompilation error
Dfalse
Attempts:
2 left
💡 Hint
Remember that && returns true only if both sides are true.
Predict Output
intermediate
2:00remaining
What does this Kotlin code print using logical OR (||)?
Look at this Kotlin code. What will be printed?
Kotlin
fun main() {
    val x = false
    val y = false
    println(x || y)
}
ARuntime exception
Bfalse
CCompilation error
Dtrue
Attempts:
2 left
💡 Hint
|| returns true if at least one operand is true.
Predict Output
advanced
2:00remaining
What is the output of this Kotlin code using NOT (!) operator?
What will this Kotlin program print?
Kotlin
fun main() {
    val flag = true
    println(!flag)
}
Afalse
Btrue
CCompilation error
DRuntime exception
Attempts:
2 left
💡 Hint
The ! operator reverses the boolean value.
Predict Output
advanced
2:00remaining
What is the output of this Kotlin code combining &&, ||, and !?
Analyze this Kotlin code and determine what it prints.
Kotlin
fun main() {
    val a = true
    val b = false
    val c = true
    println((a && !b) || (b && c))
}
ACompilation error
Bfalse
Ctrue
DRuntime exception
Attempts:
2 left
💡 Hint
Evaluate !b first, then &&, then ||.
🧠 Conceptual
expert
3:00remaining
Which Kotlin expression evaluates to false?
Given these variables: val p = false, val q = true, which expression evaluates to false?
A!p && !q
Bp && !q || q
Cp || q && !p
D!q && p || q
Attempts:
2 left
💡 Hint
Evaluate each expression step by step using operator precedence.