top of page

What are the 5 types of inheritance in Java?

  • Writer: Akshay Sharma
    Akshay Sharma
  • Oct 14, 2022
  • 2 min read

Did you know that prior to its current name, Java was referred to as “Oak”? Well, we certainly are grateful they didn’t stick to its former title. In this article we are going to discuss 5 types of inheritance on java.


By “they” we are referring to the Sun Microsystems who have designed the ultimate object-oriented prodigy- “Java”.


There are countless applications and web pages that have been designed till date using the Java programming language. But what really plays a key role here?


It has only been possible due to the multiple inheritances in Java. They have collectively facilitated the designing and execution of web programs.


In this blog, you will find an elaborate discussion on the 5 different types of inheritances available in Java.


Also since we are on the topic of Java, it is only fair to discuss one of its most important concepts.


By the end of this blog, we have briefly mentioned the subject of String palindrome in Java.

What are the 5 types of inheritance in Java?

Inheritance in one of the most basic terms can be explained by the following example:

Have you taken notice of how children often inherit the qualities or traits of their parents?

In the programming language of Java, when one class acquires the properties of the other, the process is referred to as Inheritance.

Why is it useful you may ask?

Since the classes are inhibiting the properties of their former class, we can utilize the similar methods and fields of the former class while running a program.


The phenomenon of inheritance is arguably one of the most stand-out qualities of an object oriented programming language such as Java.


Now, The Java programming language facilitates the process of inheritance in 6 different formats. They are as follows:

Single inheritance

This mechanism revolves around the creation of a superclass also commonly referred to as the parent class, using a subclass in Java.


Let us refer to the following example for better understanding:


A———— B


A and B are two classes in Java. A class in Java is basically a cumulation of objects that exhibit similar qualities.


Now, class A is extended towards class B. This means that the class B is inheriting qualities of class A which facilitates reusability for the programmer.


This makes class A- The sub class and class B- The super class. Note that the sub class is extending or leading to the formation of the parent and not the other way around.

Multiple inheritance

Staying true to its name, the phenomenon of multiple inheritance in Java is referred to the formation of multiple superclasses by the extension of various subclasses.


Object oriented programming languages are characterised for facilitating multiple inheritances, except for Java.


 
 
 

Recent Posts

See All

Comments


Drop Me a Line, Let Me Know What You Think

Thanks for submitting!

© 2023 by Train of Thoughts. Proudly created with Wix.com

bottom of page