OOP’S Concept Inheritance
- Can access the property of one class into another class.
- To achieve Inheritance In Java extends keyword is use in java
- Can Access only non-private properties of parent class into child class.
- There are total 5 types of inheritance in OOPs and from this only 3 are directly allowed in java.
- In Java one class can extend only one class at a time. (Once class can extends maximum one class)
- Constructors are not a part of inheritance (Constructor never inherits)
- Multiple and Hybrid inheritance is not supported in java directly, but it can be achieved by Interface.
- Multiple and Hybrid inheritance is not allowed in java due to ambiguity/confusion in accessing the same properties.
- After Inheritance IS-A relation applies between Parent and child class.
- Advantage of Inheritance
- Code reusability, extensibility.
- Inheritance is required to achieve runtime polymorphism.
Join Telegram : Click Here