This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In overriden version of method calls is dicide at runtime based on object type which means it is "Dynamic method dispatch" but in overloading version of method calls it depends on the reference type not the object type at compile time. Why dynamic method dispatch wont work in overloading version of method calls.
Prasad, the difference is that when you are calling an overridden method, it's being called on the polymorphic object - but when you are calling an overloaded method, you are passing a reference.
Consider the following code which shows an example of each:
In Example 1 the action uses an object, not a reference. The object is a B and knows that it is a B.
Example 2 uses a reference. The reference has absolutely no clue what the actual object type is - the reference can only say "I know that my object implements or extends my type, so I can assure you that the API of my reference type will be valid for this object... whatever it is." It's because of this that the overloaded method must choose to pick the overloaded version that matches the reference type.
CouldJava have been implemented to allow the polymorphic overloading? Probably. I would guess the performance hit of having to grab the object and compare its actual class to all the possible overloaded possibilities wouldn't be worth it. Besides, it's rare that such a feature would really be valuable.