Inheritance in OOP using Java
A Simple Presentation on Inheritance
Concept in Java
Introduction to Inheritance
• Inheritance allows one class to acquire
properties of another class.
• It promotes code reusability and hierarchy.
• Parent class = Superclass, Child class =
Subclass.
Basic Syntax
• A child class uses the 'extends' keyword.
• Syntax Example: class Child extends Parent {}
Types of Inheritance
• Single Inheritance
• Multilevel Inheritance
• Hierarchical Inheritance
• Multiple Inheritance (through interfaces only)
Single Inheritance
• One subclass inherits one superclass.
• Example: B extends A
Multilevel Inheritance
• A class inherits another derived class.
• Example: C extends B and B extends A
Hierarchical Inheritance
• Multiple subclasses inherit from one
superclass.
• Example: B and C both extend A
Advantages of Inheritance
• Code reusability
• Reduces redundancy
• Improves maintainability
• Supports polymorphism
Conclusion
• Inheritance is a core feature of OOP in Java.
• It helps in creating reusable and organized
code structures.