Kotlin and Android Practice Test 2025 – Complete Exam Prep Guide

Question: 1 / 400

Which of the following is NOT a way to create a comment in Kotlin?

Add // at the beginning of a line

Put /* to start a block comment

Use // to turn the entire function into a comment

Use /* to start a comment that is one line long

In Kotlin, comments are used to annotate the code and can enhance its readability. There are two primary ways to create comments: single-line comments and multi-line (block) comments.

When creating a single-line comment, you can start a line with `//`. Everything following `//` on that line will be treated as a comment. This is a straightforward method for adding comments to code.

For multi-line comments, you start with `/*` and end with `*/`. This allows you to encapsulate several lines of code or text as a comment. However, using `/*` to initiate a comment that is intended to cover just one line is somewhat unconventional, as its primary use is meant for longer, block structures.

The provided answer highlights that using `/*` to start a comment that is just one line long is not standard practice in Kotlin. While it technically functions to create a comment, the intention behind the way comments are typically written in Kotlin prefers the single-line format for brevity and clarity when only one line is necessary. Thus, the specific phrasing of that answer indicates a lack of clarity regarding the proper context for beginning comments.

Get further explanation with Examzify DeepDiveBeta
Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy