Some one asked me What is difference between Polymorphism and Overriding
in Java and similarly difference between
Polymorphism and Overloading. Well they are not two different thing, Polymorphism
is an object oriented or OOPS concept like Abstraction, Encapsulation
or Inheritance
which facilitate use of interface and allows Java program to take advantage of
dynamic binding in Java. Polymorphism is also a way though which a Type can
behave differently than expected based upon which kind of Object it is
pointing. Overloading and overriding are two forms of Polymorphism available in
Java. Both overloading
and overriding
concept is applied on methods in Java. Since polymorphism literally
means taking multiple forms, So even though you have name of the method same in
case of overloading and overriding, actual method called can be any of those
multiple methods with same name. Let's see some more details on method
overloading and overriding to understand how polymorphism relates to
overloading and overriding and How they are different.