inheritance natural way to organize various structural components of software package is in hierarchical fashionwith similar abstract definitions grouped together in level-by-level manner that goes from specific to more general as one traverses up the hierarchy an example of such hierarchy is shown in figure using mathematical notationsthe set of houses is subset of the set of buildingsbut superset of the set of ranches the correspondence between levels is often referred to as an "is arelationshipas house is buildingand ranch is house building apartment low-rise apartment commercial building house high-rise apartment two-story house ranch skyscraper figure an example of an "is ahierarchy involving architectural buildings hierarchical design is useful in software developmentas common functionality can be grouped at the most general levelthereby promoting reuse of codewhile differentiated behaviors can be viewed as extensions of the general casein object-oriented programmingthe mechanism for modular and hierarchical organization is technique known as inheritance this allows new class to be defined based upon an existing class as the starting point in object-oriented terminologythe existing class is typically described as the base classparent classor superclasswhile the newly defined class is known as the subclass or child class there are two ways in which subclass can differentiate itself from its superclass subclass may specialize an existing behavior by providing new implementation that overrides an existing method subclass may also extend its superclass by providing brand new methods