Bird
0
0

What is wrong with the following Kotlin code?

medium📝 Debug Q6 of 15
Kotlin - Basics and JVM Runtime
What is wrong with the following Kotlin code?
fun main() {
    /* Start of comment
    println("Hello")
}
AThe println statement is outside the function
BThe multi-line comment is not closed
CThe function main() is missing a return type
DSingle-line comments cannot span multiple lines
Step-by-Step Solution
Solution:
  1. Step 1: Check comment syntax

    The multi-line comment starts with /* but there is no closing */.
  2. Step 2: Understand impact

    Without closing */, the compiler treats the rest as comment, causing an error.
  3. Final Answer:

    The multi-line comment is not closed -> Option B
  4. Quick Check:

    Always close multi-line comments with */ [OK]
Quick Trick: Multi-line comments must be closed with */ [OK]
Common Mistakes:
MISTAKES
  • Forgetting to close multi-line comments
  • Confusing comment errors with function syntax
  • Assuming single-line comments can be multi-line

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes