Java – Inheritance

Inheritance:

  • Defining a new class by re-using the members of other class.
  • We can implement inheritance using “extends” keyword.
  • Terminology:
    • Parent/Super class: The class from which members are re-used.
    • Child/Sub class: The class which is using the members

Types of Inheritance:

  1. Single Inheritance
  2. Multi-Level Inheritance
  3. Hierarchical Inheritance

Note: We can achieve above relations through classes

Single Inheritance:

Multi-Level Inheritance:

Hierarchical Inheritance:

The two other inheritance types are:

  1. Multiple Inheritance
  2. Hybrid Inheritance

We cannot achieve multiple inheritance through Classes:

Scroll to Top