✏️ Explanatory Question

Types of Inheritance in java

👁 247 Views
📘 Detailed Answer
💡

Answer with Explanation

In Java, there are five types of inheritance:

  1. Single Inheritance: In single inheritance, a class extends only one base class.

  2. Multilevel Inheritance: In multilevel inheritance, a derived class is created from a base class, which itself is derived from another base class.

  3. Hierarchical Inheritance: In hierarchical inheritance, a base class has multiple derived classes.

  4. Multiple Inheritance (through interfaces): In multiple inheritance, a class can inherit from multiple interfaces.

  5. Hybrid Inheritance: Hybrid inheritance is a combination of multiple inheritance and hierarchical inheritance. It is achieved by implementing multiple interfaces and using them to create a hierarchical class structure.