Bird
0
0

Identify the error in this Kotlin code snippet:

medium📝 Debug Q6 of 15
Kotlin - Basics and JVM Runtime
Identify the error in this Kotlin code snippet:
println("Hello")
print(World)
Aprint() cannot be used after println()
BMissing parentheses in println()
CMissing quotes around World in print()
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Check println("Hello")

    This is correct syntax.
  2. Step 2: Check print(World)

    World is not in quotes, so Kotlin treats it as a variable, which is undefined.
  3. Final Answer:

    Missing quotes around "World" in print() -> Option C
  4. Quick Check:

    String literals must be in quotes [OK]
Quick Trick: String literals require quotes in print statements [OK]
Common Mistakes:
MISTAKES
  • Forgetting quotes around string literals
  • Assuming print() needs parentheses omitted
  • Thinking print() cannot follow println()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes