1.

Explain the difference between a Class and an Object with an example.

Answer»

1. A class is a physical or logical entity that has certain attributes. A class is a template from which objects are created. Object is an instance of a class . 

2. Class book can have title, author, publisher, price as the data members. To display the details of class book you would call the method member display() Method members of a class are invoked through the object like book1 to perform the action associated with that method

Class is a blueprint or template from which objects are created. 
Object is a real world entity such as pen, laptop, mobile, bed, keyboard, mouse, chair etc. Class is a group of similar objects. Object is a physical entity.


Discussion

No Comment Found

Related InterviewSolutions