Bird
0
0

What is the output of the following Kotlin code?

medium📝 Predict Output Q13 of 15
Kotlin - Functions
What is the output of the following Kotlin code?
fun multiply(x: Int, y: Int): Int {
    return x * y
}

fun main() {
    println(multiply(3, 4))
}
A12
B34
C7
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the multiply function

    The function takes two integers and returns their product using return x * y.
  2. Step 2: Calculate the function call multiply(3, 4)

    3 multiplied by 4 equals 12, so the function returns 12.
  3. Final Answer:

    12 -> Option A
  4. Quick Check:

    3 * 4 = 12 [OK]
Quick Trick: Multiply parameters and check return value [OK]
Common Mistakes:
MISTAKES
  • Adding instead of multiplying
  • Concatenating numbers as strings
  • Assuming syntax error due to missing expression body

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes