Curriculum
Classes and Objects in Java are the foundation of Object-Oriented Programming (OOP). Java is an object-oriented programming language, and almost every Java application is built using classes and objects.
In this Core Java course in Jaipur, students will learn what classes and objects are, how they work in Java, object creation, class members, methods inside classes, and real-world applications used in software development.
Classes and objects are widely used in:
Understanding classes and objects in Java helps students build real-world software applications using object-oriented programming concepts.
A class in Java is a blueprint or template used to create objects.
A class contains:
Classes help developers organize related data and functions together.
Example:
Car
A car class may contain:
And methods like:
class ClassName {
// variables
// methods
}
class Student {
int rollNumber;
String name;
}
An object in Java is an instance of a class.
Objects are used to:
If:
Car
is a class,
then:
BMW, Audi, Tesla
are objects.
Objects are created using:
new
keyword.
ClassName objectName = new ClassName();
class Student {
int rollNumber;
String name;
public static void main(String[] args) {
Student s1 = new Student();
s1.rollNumber = 101;
s1.name = "Rahul";
System.out.println(s1.rollNumber);
System.out.println(s1.name);
}
}
101
Rahul
Here:
Student s1 = new Student();
creates object:
s1
Object:
s1
accesses variables:
Variables declared inside class but outside methods are called:
Example:
int rollNumber;
String name;
Each object gets its own copy of instance variables.
Objects access variables and methods using:
dot operator (.)
Example:
s1.name
Classes can contain methods.
class Employee {
int id;
String name;
void display() {
System.out.println(id + " " + name);
}
public static void main(String[] args) {
Employee e1 = new Employee();
e1.id = 1;
e1.name = "Amit";
e1.display();
}
}
1 Amit
A class can create multiple objects.
class Car {
String brand;
public static void main(String[] args) {
Car c1 = new Car();
Car c2 = new Car();
c1.brand = "BMW";
c2.brand = "Audi";
System.out.println(c1.brand);
System.out.println(c2.brand);
}
}
BMW
Audi
Objects are stored in:
Reference variables are stored in:
Objects without reference variables are called anonymous objects.
new Student();
Objects represent:
Objects represent:
Objects represent:
Objects represent:
Classes and objects provide:
| Class | Object |
|---|---|
| Blueprint | Instance of class |
| Logical entity | Physical entity |
| No memory allocated | Memory allocated |
Incorrect:
name = "Rahul";
Methods and variables cannot be accessed without objects in non-static context.
Java class names should start with uppercase letters.
Understanding classes and objects helps students:
In this lesson, students learned:
These concepts are essential for Object-Oriented Programming and Java software development.
A class is a blueprint used to create objects.
An object is an instance of a class.
They help build modular and real-world applications using object-oriented programming.
Instance variables are variables declared inside class but outside methods.
Objects are created using new keyword.
Yes, a single class can create multiple objects.
WhatsApp us