Bird
0
0

Why does the expression true || false && false evaluate to true in Kotlin?

hard📝 Conceptual Q10 of 15
Kotlin - Data Types
Why does the expression true || false && false evaluate to true in Kotlin?
ABecause OR (||) has higher precedence than AND (&&)
BBecause both operators have equal precedence and evaluate left to right
CBecause AND (&&) has higher precedence than OR (||)
DBecause Kotlin evaluates expressions randomly
Step-by-Step Solution
Solution:
  1. Step 1: Recall operator precedence

    AND (&&) has higher precedence than OR (||) in Kotlin.
  2. Step 2: Evaluate expression accordingly

    Evaluate false && false first (false), then true || false = true.
  3. Final Answer:

    AND has higher precedence than OR, so expression evaluates to true -> Option C
  4. Quick Check:

    Operator precedence: && before || [OK]
Quick Trick: AND (&&) is evaluated before OR (||) in Kotlin [OK]
Common Mistakes:
MISTAKES
  • Assuming OR has higher precedence
  • Evaluating left to right ignoring precedence
  • Thinking Kotlin evaluates randomly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes