A class hierarchy or inheritance tree in
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
is a classification of
object types, denoting objects as the instantiations of
classes (class is like a blueprint, the object is what is built from that blueprint) inter-relating the various classes by relationships such as "inherits", "extends", "is an abstraction of", "an interface definition".
In
object-oriented programming
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
, a class is a template that defines the state and behavior common to objects of a certain kind. A class can be defined in terms of other classes.
The concept of class hierarchy in computer science is very similar to
taxonomy
image:Hierarchical clustering diagram.png, 280px, Generalized scheme of taxonomy
Taxonomy is a practice and science concerned with classification or categorization. Typically, there are two parts to it: the development of an underlying scheme o ...
, the classifications of species.
The relationships are specified in the science of
object-oriented design and object interface standards defined by popular use, language designers (
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
C++,
Smalltalk
Smalltalk is a purely object oriented programming language (OOP) that was originally created in the 1970s for educational use, specifically for constructionist learning, but later found use in business. It was created at Xerox PARC by Learni ...
,
Visual Prolog) and standards committees for software design like the
Object Management Group.
The class hierarchy can be as deep as needed. The instance variables and methods are inherited down through the levels and can be redefined according to the requirement in a subclass. In general, the further down in the hierarchy a class appears, the more specialized its behavior. When a message is sent to an object, it is passed up the inheritance tree starting from the class of the receiving object until a definition is found for the method. This process is called upcasting.
See also
*
Multiple inheritance
*
Composition over inheritance
References
{{DEFAULTSORT:Class Hierarchy
Class (computer programming)