Bird
0
0

Why does Kotlin evaluate multiplication before addition in expressions like 2 + 3 * 4?

hard📝 Conceptual Q10 of 15
Kotlin - Operators and Expressions
Why does Kotlin evaluate multiplication before addition in expressions like 2 + 3 * 4?
ABecause multiplication has higher operator precedence than addition
BBecause addition is always evaluated last in all languages
CBecause Kotlin evaluates operators from right to left
DBecause parentheses are required to change order
Step-by-Step Solution
Solution:
  1. Step 1: Understand operator precedence concept

    Operator precedence defines which operations happen first without parentheses.
  2. Step 2: Check Kotlin's precedence rules

    Multiplication (*) has higher precedence than addition (+), so it is evaluated first.
  3. Final Answer:

    Because multiplication has higher operator precedence than addition -> Option A
  4. Quick Check:

    Operator precedence controls evaluation order [OK]
Quick Trick: Higher precedence operators run first [OK]
Common Mistakes:
MISTAKES
  • Thinking evaluation is right to left
  • Assuming addition always last
  • Ignoring operator precedence rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes