Bird
0
0

What will be the output of this Kotlin program?

medium📝 Predict Output Q4 of 15
Kotlin - Basics and JVM Runtime
What will be the output of this Kotlin program?
fun main() {
    println("Hello")
    println("World")
}
AHello World
BWorld Hello
CHello World
DCompilation error
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the main function

    The main function prints two lines: "Hello" and then "World".
  2. Step 2: Understand println behavior

    Each println outputs the string followed by a newline.
  3. Final Answer:

    Hello World -> Option A
  4. Quick Check:

    Output matches the order of println calls [OK]
Quick Trick: println prints with newline by default [OK]
Common Mistakes:
MISTAKES
  • Assuming println prints on the same line
  • Confusing the order of output lines
  • Expecting a compilation error due to syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes