Object & Class in Java


No.
Object
Class
1)
Object is an instanceof a class.
Class is a blueprint or templatefrom which objects are created.
2)
Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc.
Class is a group of similar objects.
3)
Object is a physicalentity.
Class is a logicalentity.
4)
Object is created through new keywordmainly e.g.
Student s1=new Student();
Class is declared using class keyworde.g.
class Student{}
5)
Object is created many times as per requirement.
Class is declared once.
6)
Object allocates memory when it is created.
Class doesn't allocated memory when it is created.
7)
There are many ways to create object in java such as new keyword, newInstance() method, clone() method, factory method and deserialization.
There is only one way to define class in java using class keyword.
loading...

No comments:

Powered by Blogger.