Lably
Skip to content

Class (programming)

Computer programming structure used to create objects

  • 25 min read
  • 8 chapters

Learn it on Lably

Object state can differ between each instance of the class whereas the class state is shared by all of them. The object methods include access to the object state (via an implicit or explicit parameter that references the object) whereas class methods do not.

If the language supports inheritance, a class can be defined based on another class with all of its state and behavior plus additional state and behavior that further specializes the class. The specialized class is a sub-class, and the class it is based on is its superclass.

In purely object-oriented programming languages, such as Java and C#, all classes might be part of an inheritance tree such that the root class is Object, meaning all objects instances are of Object or implicitly extend Object, which is called a top type.

History

The concept was introduced in object-oriented programming by the Simula language in the 1960s and has been in continuous use in many programming languages since. Its creation was based in similar concept as block used in the earlier ALGOL 60 programming language.

Sign in to keep reading

7 more chapters are free with a Lably account.

More in Computing and communication