| |
|
Define Inheritance in Python with some examples?
As we knows Python is object-oriented programming paradigm and classes in Pyhton have ability to inherit the properties of another class. And this process is called inhertitance. Inheritance provides the code reusability feature. The class that is being inherited is called a superclass or the parent class, and the class that inherits the superclass is called a derived or child class. Below are types of inheritance as given in Picture:-
(1)Single inheritance:-In python when a class inherits only one of superclass.
(2)Multiple inheritance:-In Python when a class inherits multiple superclasses.
(3)Multilevel inheritance:-In Python when a class inherits a superclass and then another class inherits this derived class forming a ‘parent, child, and grandchild’ class structure.
(4)Hierarchical inheritance:-In python when one of the superclass is inherited by multiple derived classes. | |
|
|
|
|