In object-oriented
programming (OOP), Inheritance is a way to compartmentalize and reuse
code by creating collections of attributes and behaviors called objects
which can be based on previously created objects. In classical
inheritance where objects are defined by classes, classes can inherit
other classes. The new classes, known as Sub-classes (or derived
classes), inherit attributes and behavior of the pre-existing classes,
which are referred to as Super-classes (or ancestor classes). The
inheritance relationship of sub- and superclasses gives rise to a
hierarchy. In Prototype-based programming objects can be defined
directly from other objects without the need to define any classes.