What are comments in Java?

Prepare for the Computer Programming Test. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

Multiple Choice

What are comments in Java?

Explanation:
Comments are explanatory notes in the source code that are ignored by the compiler, so they don’t affect how the program runs. They’re there to help someone reading the code understand what it does or why a particular implementation was chosen. In Java you can write a single-line comment with //, a multi-line comment with /* ... */, or a Javadoc comment with /** ... */ for generating documentation. Use comments to describe the purpose of classes, methods, parameters, or any tricky logic, and to leave notes for future readers. They’re not data declarations or executable statements; writing text in quotes would create a string instead of a comment.

Comments are explanatory notes in the source code that are ignored by the compiler, so they don’t affect how the program runs. They’re there to help someone reading the code understand what it does or why a particular implementation was chosen. In Java you can write a single-line comment with //, a multi-line comment with /* ... /, or a Javadoc comment with /* ... */ for generating documentation. Use comments to describe the purpose of classes, methods, parameters, or any tricky logic, and to leave notes for future readers. They’re not data declarations or executable statements; writing text in quotes would create a string instead of a comment.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy