Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
RUNTIME
POLYMORPHISM, DYNAMIC
BINDING, OVERRIDING
Swapnali Kurhade
Sardar Patel Institute of Technology
Method Overriding
Declaring a method in subclass which is already
present in parent class is known as method
overriding.
Advantage
The class can give its own specific implementation to
a inherited method without even modifying the
parent class(base class).
Method overriding is used for runtime polymorphism
Example…
class Human{
public void walk() { System.out.println("Human walks"); }
}
class Boy extends Human{
public void walk() { System.out.println("Boy walks"); }
2) Method overloading is performed within Method overriding occurs in two classes that
class. have IS-A (inheritance) relationship.
4) Method overloading is the example of Method overriding is the example of run time
compile time polymorphism. polymorphism.