Inheritance is the process that, expanding and improving its capabilities, enables new classes to be form out of existing classes. Furthermore, The current classes are refer to as the base classes/parent classes/super-classes, and the derive classes/child classes/subclasses are consider the new classes.
The subclass can inherit or derive the super-class(es) attributes and methods, given that the super-class allows so. Besides, the subclass can add its own attributes and methods and can change any of the superclass methods. Inheritance describes a relationship between ‘is-a’. Further describe the types of inheritance.
Types of inheritance
Different types of inheritance, defined below :
- Single Inheritance : A single super-class is derive from a subclass. It is ridiculously simple to understand a single inheritance. A single inheritance occurs when a class extends only one other class.
- Multiple Inheritance : A subclass derives from more than one super-class. The issue with “multiple inheritance” is that the derived class will have to deal with two base classes’ dependencies.
- Multilevel Inheritance : A subclass is derive from a super-class that is in turn derived from another class and so on.
- Hierarchical Inheritance : A class has a number of subclasses, each of which may have subclasses, continuing for a number of levels in order to form a tree structure.
- Hybrid Inheritance : A mixture of multiple and multi-level inheritance to create a lattice structure.
Interested in learning about similar topics? Here are a few hand-picked blogs for you!