A class is a blueprint used to create objects by defining their properties and behaviors.
Blueprint:
A class is called a blueprint because it defines the structure and behavior for objects, but does not create any object itself. Itβs like a template.
Variables => (Properties / Data)
Methods => (Functions / Actions )
Example :
Car:
Properties => (Color , model , Speed)
Actions => (Star() , Stop() )
This one class , You can create many Objects
Class Rules:
- Starts with a Uppercase letter:
Example:
BankAccount
- Meaningful Name:
Example:
UserProfile
- Don't use the Special Charecters:
Except _ and $ it's technically allowed but using avoid.
Example:
StudentData
Student_Data β
- File Name = Class Name:
Must match the File Name and Class Name.
Example:
public class Home{
}
**File Name:** Home.java
- Do not use reserved keywords:
Java already have a keywords with a meaningful so they cannot be used class names , variable names , or method names.
Common Java Keywords:
int class if else for while static
- Prefer Singular names: A class usually represent a single object.
Example:
Home
Homes β
Top comments (0)