Bird
0
0

What will be printed by this Kotlin code?

medium📝 Predict Output Q5 of 15
Kotlin - Data Types
What will be printed by this Kotlin code?
val a = false
val b = true
val c = false
println(a || b && c)
Atrue
Bfalse
CCompilation error
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate AND operator first

    b && c is true && false = false.
  2. Step 2: Evaluate OR operator

    a || (b && c) becomes false || false = false.
  3. Final Answer:

    The output is false -> Option B
  4. Quick Check:

    Operator precedence and evaluation = B [OK]
Quick Trick: AND (&&) is evaluated before OR (||) in Kotlin [OK]
Common Mistakes:
MISTAKES
  • Evaluating OR before AND
  • Assuming OR with false is true
  • Confusing variable values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes