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 Naming Convention

← All stacks

Theory

27/270

Java Naming Convention

Java names follow a house style so teammates can read your code. Classes: PascalCase — StudentService, BankAccount. Methods and variables: camelCase — calculateTotal, studentName.

Constants: UPPER_SNAKE — MAX_SIZE, DEFAULT_TIMEOUT. Packages: lowercase with dots — com.company.app. Prefer daysLeft over d. The name should say the purpose.

Wrong style looks amateur: class student, or method CalculateTotal. Recite the four styles in fifteen seconds in an interview.

Let's take this on the board with one tiny Main class — no extra files. Java Naming Convention — output: 3 then 100. studentCount is camelCase; MAX_MARKS is a constant. Class names like Student use PascalCase. Start from main, go line by line, and stop at each print. That output is the proof for Naming Convention.

Exam tip

Four styles: class, method, constant, package — with one example each.

Example

// Naming convention
public class Main {
  public static void main(String[] args) {
    int studentCount = 3;
    final int MAX_MARKS = 100;
    System.out.println(studentCount);
    System.out.println(MAX_MARKS);
  }
}

Java Naming Convention — output: 3 then 100. studentCount is camelCase; MAX_MARKS is a constant. Class names like Student use PascalCase.

Short notes

  • DefNaming conventions make Java code readable for the team.
  • RuleClass PascalCase. method/var camelCase. CONST UPPER_SNAKE. package lowercase.
  • RememberName the purpose — daysLeft, not d.
  • Trapclass student or CalculateTotal mixing styles.

Questions

1

How do you name a class?

2

How do you name a method?

3

How do you name a constant?

4

How do you name a package?

Previous← OOPs Concepts in JavaNextJava Classes and Objects →
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.