Thursday, 20 August 2015

Java Tutorial : Inheritance Types

🔥 Master Java Programming with Us!

Level up your coding skills! Subscribe to Ram N Java for the best tutorials.

SUBSCRIBE TO CHANNEL

Understanding the Different Types of Java Inheritance

Inheritance is one of the pillars of Object-Oriented Programming (OOP) in Java. It allows a class to acquire the properties and behaviors of another class. But did you know there are multiple ways to structure these relationships? Let's dive into the different types of inheritance Java supports.

1. Single Inheritance

This is the simplest form where one child class inherits from one parent class. It creates a direct link between the two.

Example: Class B extends Class A.

2. Multilevel Inheritance

In this type, a class inherits from a child class, creating a "chain" of inheritance. Think of it like Grandparent -> Parent -> Child.

Example: Class C extends Class B, and Class B extends Class A.

3. Hierarchical Inheritance

This occurs when multiple child classes inherit from the same single parent class. This is very common in real-world applications where different objects share a common base.

Example: Both Class B and Class C extend Class A.

Wait, What About Multiple Inheritance?

Java does not support multiple inheritance with classes (where one class extends two parents) to avoid complexity and the "Diamond Problem." However, you can achieve this using Interfaces!

Explore More Java Lessons


Click here to watch in Youtube :
https://www.youtube.com/watch?v=4JGA20J3kls&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial : Inheritance Types 
Java Tutorial : Inheritance Types 
See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • 2 comments:

    Tutorials