Hello everyone 👋
This is my Day 2 learning blog on Java programming.
As a beginner, I’m sharing what I learned about Class and Object in a simple and easy-to-understand way.
If you are new to Java, this blog will help you understand the foundation of Java and OOP.
🔹 What is a Class in Java?
A class is a blueprint or template used to create objects.
• It defines properties (variables) and behaviors (methods)
• A class does not occupy memory until an object is created
Example:
class Student {
int id;
String name;
}
Here, Student is a class with two variables: id and name.
🔹 What is an Object in Java?
An object is an instance of a class.
• Objects represent real-world entities
• Memory is allocated when an object is created
• Objects are created using the new keyword
Example:
Student s1 = new Student();
Here, s1 is an object of the Student class.
🔹 Real-World Analogy
• Class → Blueprint of a house
• Object → Actual house built from the blueprint
You can create many objects from one class.
🔹 Conclusion
Understanding Class and Object is the foundation of Java and OOP.
Once this concept is clear, learning advanced Java topics becomes much easier.
This is what I learned on Day 2 of Java, and I’ll continue sharing my journey. 🚀
Top comments (0)