What is the difference between an object and a class?

An object is the basic unit of object oriented programing. It is created from a class. Every object belongs to a class and every class contains one or more related objects. The class defines what kind of data is an object, as well as what operations can be performed on such an object.

A class is also static, which means that all the attributes of a class are fixed before, during, and after the execution of a program. Similarly, the class to which an object belongs to also usually static, which means that, it will not change since the time it has been created till the time it is destroyed.

However, an object has a limited lifespan, unlike a class. The objects are created and eventually destroyed. Also the attributes of the object may change over its lifetime.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.