0
0
Kotlinprogramming~5 mins

Comments and documentation syntax in Kotlin - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the syntax for a single-line comment in Kotlin?
Use two forward slashes // before the comment text. Everything after // on that line is ignored by the compiler.
Click to reveal answer
beginner
How do you write a multi-line comment in Kotlin?
Start with /* and end with */. Everything between these markers is treated as a comment, even if it spans multiple lines.
Click to reveal answer
intermediate
What is the purpose of KDoc in Kotlin?
KDoc is Kotlin's documentation syntax. It helps you write clear explanations for classes, functions, and properties that tools can use to generate documentation.
Click to reveal answer
intermediate
How do you write a KDoc comment for a function in Kotlin?
Use /** ... */ before the function. Inside, you can add descriptions and tags like @param and @return to explain parameters and return values.
Click to reveal answer
advanced
Can you nest multi-line comments in Kotlin?
Yes, Kotlin allows nesting multi-line comments. You can start a new /* ... */ comment inside another multi-line comment.
Click to reveal answer
Which symbol starts a single-line comment in Kotlin?
A/*
B<!--
C#
D//
How do you write a multi-line comment in Kotlin?
A/* comment */
B# comment
C<!-- comment -->
D// comment
What is the correct way to start a KDoc comment?
A/**
B/*
C//
D<!--
Which tag is used in KDoc to describe a function parameter?
A@throws
B@return
C@param
D@author
Can multi-line comments be nested in Kotlin?
ANo
BYes
COnly in single-line comments
DOnly in KDoc comments
Explain the different types of comments available in Kotlin and when to use each.
Think about quick notes, longer explanations, and documentation.
You got /4 concepts.
    Describe how to write a KDoc comment for a function including parameters and return value.
    Imagine explaining your function to a friend who will use it.
    You got /4 concepts.