A class is the definition of an object, and an object is an instance of a class.
We can look at the class as a template of the object: it describes all the properties, methods, states, and behaviors that the implementing object will have.
On the other hand, an object is an instance of a class, and a class does not become an object until it is instantiated. There can be more instances of objects based on the one class, each with different properties.
| Class | Object |
|---|---|
| A piece of the program’s source code | An entity in a running program |
| Specifies the structure (the number and types) of its objects’ attributes — the same for all of its objects | Holds specific values of attributes; these values can change while the program is running |
| Specifies the possible behaviors of its objects | Behaves appropriately when called upon |

Leave a comment