Core Java

Java Inheritance – Single Level and Multilevel Inheritance Explained (Hindi & English)

Java Inheritance – Single Level and Multilevel Inheritance Explained

By Bhau Automation • Understand Java Inheritance with real examples (Hindi + English)

🎯 What You Will Learn in This Video

  • What is Inheritance in Java?
  • Single Level Inheritance explained with example
  • Multilevel Inheritance and how it works
  • Real-world analogy of inheritance
  • Relationship between inheritance and polymorphism
  • Simple explanation in Hindi & English
💡 Tip: Inheritance allows you to reuse existing code by creating a new class that inherits fields and methods from another class.

📘 What is Inheritance?

Inheritance in Java is an Object-Oriented Programming (OOP) concept where one class can acquire properties and behavior (methods) from another class using the extends keyword.

It helps in code reusability and establishing a parent-child relationship between classes.

🔹 Syntax of Inheritance

class Parent {
    void display() {
        System.out.println("This is the Parent class");
    }
}

class Child extends Parent {
    void show() {
        System.out.println("This is the Child class");
    }
}

public class InheritanceExample {
    public static void main(String[] args) {
        Child c = new Child();
        c.display(); // Inherited from Parent
        c.show();    // Defined in Child
    }
}
  

💡 Output

This is the Parent class
This is the Child class
  

🔸 Types of Inheritance in Java

Java supports the following types of inheritance:

  • Single Inheritance
  • Multilevel Inheritance
  • Hierarchical Inheritance
  • Multiple Inheritance (achieved using Interfaces)

🌳 Single Level Inheritance Example

class Animal {
    void eat() {
        System.out.println("Eating...");
    }
}

class Dog extends Animal {
    void bark() {
        System.out.println("Barking...");
    }
}

public class SingleLevelDemo {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.eat();
        d.bark();
    }
}
  

💡 Output

Eating...
Barking...
  

🌲 Multilevel Inheritance Example

class Animal {
    void eat() {
        System.out.println("Eating...");
    }
}

class Dog extends Animal {
    void bark() {
        System.out.println("Barking...");
    }
}

class Puppy extends Dog {
    void weep() {
        System.out.println("Weeping...");
    }
}

public class MultilevelDemo {
    public static void main(String[] args) {
        Puppy p = new Puppy();
        p.eat();
        p.bark();
        p.weep();
    }
}
  

💡 Output

Eating...
Barking...
Weeping...
  

🧠 Key Concepts in Java Inheritance

  • extends keyword is used to inherit a class.
  • The class being inherited is called Parent (Superclass).
  • The class that inherits is called Child (Subclass).
  • Java does not support multiple inheritance through classes (only via interfaces).

🎥 Watch the Complete Video Tutorial

👉 Watch on YouTube: Java Inheritance Explained | Bhau Automation

🎓 Key Takeaways

  • Inheritance promotes code reuse and logical hierarchy.
  • Single-level inheritance involves one parent and one child class.
  • Multilevel inheritance involves a chain of classes.
  • Inheritance forms the basis for polymorphism in Java.
  • Use inheritance only when an “is-a” relationship exists between classes.
Next Steps: Explore how inheritance connects with method overriding and polymorphism in Java OOP concepts.

🚀 Created with ❤️ by Bhau Automation

Back to All Articles