Submitted by heartin on Mon, 09/14/2015 - 21:27
The ability to change form is known as polymorphism. Java supports different kinds of polymorphism like oveloading and overriding.
The same method name (method overloading) or operator symbol (operator overloading) can be used in different contexts.
In method overloading, multiple methods having same name can appear in a class, but with different signature. And based on the number and type of arguments we provide while calling the method, the correct method will be called.
Submitted by heartin on Sun, 09/13/2015 - 08:26
Only non-static visible instance methods can be overriden:
Private methods are not visible and hence not overriden.
Protected methods can be overriden by a subclass within the same package.
Static methods are not overriden, but they are inherited.
When you refer to a child class object using a Parent reference (e.g. Parent p = new Child()) and invoke a method, the overriden child class method will be invoked.