What is a class?
A class is a blueprint or template from which objects are created.
What is an Object?
Object is an instance of a class that represents real world entity.
Here are some of the differences between a Class and an Object:
Object Class
1. Object is an instance of a class A class is a blueprint or template from
which objects are created.
2. Object is an real-world entity such Class is a group of similar objects.
as book, computer etc.
3. Object is a physical entity. Class is a logical entity.
4. Objects are created many times. Class is defined only once.
5. Object is allocated memory when Class doesn't allocate memory when
it is created. it is created.
6. There are many ways to create object. e.g. There is only one way to define Class
- Using new operator in java using class keyword.
- using clone() method
- using deserialization
It is all about class and object.
Thanks!
No comments:
Post a Comment