PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

Java Comments

← All stacks

Theory

24/270

Java Comments

Comments are notes for humans. The compiler ignores them. Three styles: // one line, /* many lines */, /** javadoc */ for classes and methods.

Write why a tricky decision exists, not every obvious line. Don’t leave huge commented-out code forever — delete it or use git.

MCQ favourite — name all three styles. Nesting /* */ carelessly can break compilation.

Let's take this on the board with one tiny Main class — no extra files. Java Comments — comments are ignored by the compiler; only sum print runs. Start from main, go line by line, and stop at each print. That output is the proof for Comments.

Exam tip

Name //, /* */, and /** */ in one breath.

Example

// Java Comments
public class Main {
  public static void main(String[] args) {
    // This is a single-line comment
    int sum = 2 + 3; /* inline note */
    System.out.println(sum);
  }
}

Java Comments — comments are ignored by the compiler; only sum print runs.

Short notes

  • DefComments are notes for humans. Compiler ignores them.
  • Rule// one line. /* many lines */. /** javadoc */.
  • RememberExplain why, not every obvious line.
  • TrapNested /* */ can break compile.

Questions

1

Does the compiler run comments?

2

Name the three comment styles.

3

What is javadoc for?

Previous← Java ContinueNextJava Programs →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.