Bird
0
0

Find the error in this Kotlin code:

medium📝 Debug Q6 of 15
Kotlin - Operators and Expressions
Find the error in this Kotlin code:
val result = 10 / 0
println(result)
ANo error, prints 0
BDivision by zero causes runtime error
CVariable 'result' not declared
DSyntax error: missing operator
Step-by-Step Solution
Solution:
  1. Step 1: Identify division by zero

    Dividing any number by zero is not allowed and causes an error at runtime.
  2. Step 2: Confirm error type

    Kotlin throws an ArithmeticException for division by zero.
  3. Final Answer:

    Division by zero causes runtime error -> Option B
  4. Quick Check:

    Division by zero = runtime error [OK]
Quick Trick: Never divide by zero, it crashes your program [OK]
Common Mistakes:
MISTAKES
  • Thinking it prints 0
  • Expecting compile-time error
  • Ignoring runtime exceptions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes