Hi method overloading would be an example of static polymorphism whereas overriding would be an example of dynamic polymorphism.
B'Coz,in case of overloading,at compile time the compiler knows which method to link to the call . However,it is determined at runtime for dynamic polymorphism.
Please comment if i am correct on this one. Thanks for your replies. -vinny m
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
Joined: Jan 18, 2006
U are absolutely correct..
Dynamic, or late, binding occurs when a method is defined for several classes in a family, but the actual code for the method is not attached, or bound, until execution time.This gives support for overriding...
Static binding occurs when a method is defined with the same name but with different headers and implementations. The actual code for the method is attached, or bound, at compile time. Static binding is used to support overloaded methods in Java.
Joined: Dec 21, 2005
Hi vinny What you say is correct and this has been discussed many times in this forum.Which method to be called is decided at runtime only but not at compile time.At compile time it just checks whether syntax is correct or not but does not perform any operations more than that.Dont know why people have termed both as static(overloading) and dynamic(overriding) which is not even clear to me.