Solution

Solution

by Bayazid Bostami -
Number of replies: 0

1. Ans: 

Here is the important difference between class and object:

1. A class is a template for creating objects in a program, but The object is an instance of a class.

2. A class is a logical entity but an Object is a physical entity.

3. A class does not allocate memory space when it is created but an Object allocates memory space whenever they are created.

4. You can declare a class only once but You can create more than one object using a class.

5. Class generates objects but Objects provide life to the class.

2. Ans: 

Class − A class can be defined as a template/blueprint that describes the behaviour /state that the object of its type support.

For example we can say, Dog is a class.

Object − Objects have states and behaviors. 

Example: A dog has states - color, name, breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a class.