For Method Overriding (so runtime polymorphism can be achieved).
- For Code Reusability.
Syntax :-class Subclass-name extends Superclass-name { //methods and fields }
–> The extends keyword indicates that you are making a new class that derives from an existing class. The meaning of “extends” is to increase the functionality.
–> In the terminology of Java, a class which is inherited is called parent or super class and the new class is called child or subclass.
Type of Inheritance :-
0 Comments:
Post a Comment