Bird
0
0

What will be the output of this Kotlin code?

medium📝 Predict Output Q4 of 15
Kotlin - Functions
What will be the output of this Kotlin code?
fun double(x: Int) = x * 2
println(double(5))
A10
B5
C25
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function behavior

    The function doubles the input by multiplying by 2.
  2. Step 2: Calculate output for input 5

    5 * 2 = 10, so the function returns 10, which is printed.
  3. Final Answer:

    10 -> Option A
  4. Quick Check:

    double(5) = 10 [OK]
Quick Trick: Multiply input by 2 to get output [OK]
Common Mistakes:
MISTAKES
  • Confusing multiplication with addition
  • Expecting function to print inside
  • Thinking it returns input unchanged

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes