Bird
0
0

Which of the following is the correct way to write a single-line comment in Kotlin?

easy📝 Conceptual Q11 of 15
Kotlin - Basics and JVM Runtime
Which of the following is the correct way to write a single-line comment in Kotlin?
A/* This is a single-line comment */
B<!-- This is a single-line comment -->
C// This is a single-line comment
D# This is a single-line comment
Step-by-Step Solution
Solution:
  1. Step 1: Identify single-line comment syntax in Kotlin

    Kotlin uses // to start a single-line comment.
  2. Step 2: Compare options

    // This is a single-line comment uses //, which is correct. /* This is a single-line comment */ is for multi-line comments. <!-- This is a single-line comment --> is HTML style. # This is a single-line comment is used in some scripting languages but not Kotlin.
  3. Final Answer:

    // This is a single-line comment -> Option C
  4. Quick Check:

    Single-line comment = // [OK]
Quick Trick: Single-line comments start with // in Kotlin [OK]
Common Mistakes:
MISTAKES
  • Using /* */ for single-line comments
  • Using # or which are not Kotlin comments
  • Confusing multi-line and single-line comment syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes