Bird
0
0

What will this Kotlin code print?

medium📝 Predict Output Q5 of 15
Kotlin - Basics and JVM Runtime
What will this Kotlin code print?
fun main() {
    val x = 5
    val y = 10
    println(x + y)
}
A510
B15
Cx + y
DError: Cannot add variables
Step-by-Step Solution
Solution:
  1. Step 1: Identify variable types and values

    x and y are integers with values 5 and 10.
  2. Step 2: Calculate the sum

    Adding 5 + 10 equals 15, which is printed.
  3. Final Answer:

    15 -> Option B
  4. Quick Check:

    Integer addition outputs sum [OK]
Quick Trick: Adding integers prints their sum, not concatenation [OK]
Common Mistakes:
MISTAKES
  • Confusing addition with string concatenation
  • Expecting '510' as output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes