0
0
Kotlinprogramming~20 mins

Print and println output in Kotlin - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Print and println Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of print and println combination
What is the output of this Kotlin code snippet?
Kotlin
fun main() {
    print("Hello")
    println("World")
    print("!")
}
A
HelloWorld!
B
HelloWorld
!
C
Hello
World
!
D
Hello
World!
Attempts:
2 left
💡 Hint
Remember that print does not add a new line, but println does.
Predict Output
intermediate
2:00remaining
Output with multiple println calls
What will this Kotlin program print?
Kotlin
fun main() {
    println("A")
    println("B")
    println("C")
}
A
C
B
A
B
A
B
C
CABC
DA B C
Attempts:
2 left
💡 Hint
Each println adds a newline after printing.
🧠 Conceptual
advanced
2:00remaining
Difference between print and println
Which statement best describes the difference between print() and println() in Kotlin?
Aprint() outputs text with a newline; println() outputs text without a newline.
BBoth print() and println() output text with a newline at the end.
Cprint() outputs text without a newline; println() outputs text with a newline at the end.
DBoth print() and println() output text without a newline.
Attempts:
2 left
💡 Hint
Think about what happens after the text is printed.
Predict Output
advanced
2:00remaining
Output of mixed print and println with variables
What is the output of this Kotlin code?
Kotlin
fun main() {
    val x = 5
    print("x = $x")
    println(", x squared = ${x * x}")
    print("Done")
}
A
x = 5, x squared = 25
Done
Bx = 5, x squared = 25Done
C
x = 5
, x squared = 25
Done
D
x = 5
, x squared = 25Done
Attempts:
2 left
💡 Hint
Remember where println adds a newline.
Predict Output
expert
2:00remaining
Output of nested print and println calls
What is the output of this Kotlin program?
Kotlin
fun main() {
    print("Start")
    println()
    print("End")
}
AStartEnd
B
Start
End
C
Start
 End
D
Start

End
Attempts:
2 left
💡 Hint
What does println() with no arguments do?