Bird
0
0

What will be the output of the following Kotlin code?

medium📝 Predict Output Q13 of 15
Kotlin - Basics and JVM Runtime
What will be the output of the following Kotlin code?
print("Hi")
println(" there")
print("Welcome")
AHi there Welcome
BHi there Welcome
CHi there Welcome
DHi there Welcome
Step-by-Step Solution
Solution:
  1. Step 1: Trace first print statement

    print("Hi") outputs "Hi" without newline.
  2. Step 2: Trace println statement

    println(" there") outputs " there" and moves to next line.
  3. Step 3: Trace last print statement

    print("Welcome") outputs "Welcome" on the new line.
  4. Final Answer:

    Hi there Welcome -> Option D
  5. Quick Check:

    print no newline, println newline = D [OK]
Quick Trick: Remember print stays on line; println moves to next line [OK]
Common Mistakes:
MISTAKES
  • Assuming print adds newline
  • Ignoring space in " there"
  • Thinking all output is on one line

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes