How does an Object differ from a Class?
Advertisements
प्रश्न
How does an Object differ from a Class?
Advertisements
उत्तर
|
Object |
Class |
|
1. An object is an instance of a class that represents a real-world entity. |
1. A class is a blueprint or template that is used to create objects. |
|
2. An object is a physical entity that exists in memory during program execution. |
2. A class is a logical entity that defines the structure and behaviour of objects. |
|
3. An object occupies memory when it is created during the execution of a program. |
3. A class definition does not allocate memory for the instance variables of its objects. |
|
4. An object contains data members that represent its state and uses methods to perform specific operations. |
4. A class defines the data members and methods that are shared in structure by its objects. |
|
5. An object is created from a class, generally by using the |
5. A class is declared by using the |
|
6. Multiple objects can be created from a single class, and each object can have its own data values. |
6. A single class can be used to create multiple objects having similar properties and behaviours. |
|
7. Example: |
7. Example: class Car |
