List out some of the differences between a class and an object?
CLASS | OBJECT |
---|---|
It is a blueprint from which different instances (objects) are created. | Objects are the instances of the class. |
Class is a logical entity. | Objects are physical entities. |
Users can declare class only once. | Objects can be declared multiple times depending upon the requirements. |
When a class is created there is no memory allocation | Objects allocated memory. |
Class is a group of objects. | Objects are real-world entities such as pen, copy, mouse, etc. |
Class can be declared using class keyword e.g class Student {} | Objects can be declared using the new keyword e.g. Student s1=new Student(); |
BY Best Interview Question ON 03 Nov 2021