It is a mechanism by which a specific object acquires attributes and behaviors of more general objects
(Or)
Inheritance is the inclusion of state (Variables) and behavior (methods_ of a base/super class in a derived/sub class, So that they are accessible in the subclass.
- The key benefit of inheritance is that it provides the formal mechanism for “Code Reuse”.
Single
Inheritance:
- Single Inheritance is the property in which a subclass inherits certain features or properties of the super class.
- In java inheritance is achieved by using the key word “Extends”.
Multi - Level Inheritance (Multiple Inheritance):
- When a child class inherits multiple properties form multiple classes, it is known as multiple Inheritance.
- But java does not allow us to extend multiple classes, however this problem is overcome by the implementation of multiple interfaces.
No comments:
Post a Comment