You are on page 1of 6

{

METHOD OVERRIDING
BY
Jenishiya M

... }
Definition
If subclass (child class) has the same
method as declared in the parent class, it is
known as method overriding in Java.
Usage of Method Overriding
Method overriding is used for achieving
01 run-time polymorphism.

Method overriding is used for writing


02 specific definition of a subclass
method
Output:
{ .. Rules For Method Overriding
1. 2. 3.
The argument list A method declared A method declared
should be exactly the static cannot be
final cannot be
same as that of the overridden but can be
overridden method.
overridden.
re-declared.

4 5. 6.
If a method cannot be Instance methods can The return type should be
inherited, then it be overridden only if the same or a subtype of
the return type declared in
cannot be overridden. they are inherited by
the original overridden
the subclass.
method in the superclass.

} ..
{ ..

THANK
YOU
} ..

You might also like