+ 1

How many types of inheritance are there?

Please Explain the types of inheritance in java.

17th May 2019, 2:00 PM
Nikhil Anand
Nikhil Anand - avatar
2 Respostas
+ 2
There are 3 types of inheritance supported by Java: Single-Level, Multi-Level, and Hierarchical. >Single-level Inheritance A subclass inherits only from one base class. In this case there exist only 2 classes. The class which inherits and the class which itself is inherited.(Think of it like a family having a mother who has 1 child) >Multi-level Inheritance A subclass inherits from a class that itself inherits from another class. There is a class (grandchild) inheriting another subclass(child). In this case the grandchild class will have the properties of both the child and base class.((Think of it like a family having a grandmother, mother who has one or more children) >Hierarchical Inheritance Many sub classes inherit from a single base class. This is like a variation of single inheritance. There are several single level relations but all the sub classes inherit from the same base class. (Think of it like a family having a mother who has several children) NOTE : In each type a subclass can inherit from only one class. But, one class can be inherited from several classes.
17th May 2019, 3:15 PM
Naina Aggarwal
Naina Aggarwal - avatar
+ 2
Thanks
17th May 2019, 3:19 PM
Nikhil Anand
Nikhil Anand - avatar