wood burning stoves
The moose likes Java in General and the fly likes static polymorphism v/s dynamic polymorphism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "static polymorphism v/s dynamic polymorphism" Watch "static polymorphism v/s dynamic polymorphism" New topic

static polymorphism v/s dynamic polymorphism

Vinny Menon
Ranch Hand

Joined: Jan 10, 2006
Posts: 62

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

Regards,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
sarika mishra

Joined: Jan 18, 2006
Posts: 4
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.
badri nath
Ranch Hand

Joined: Dec 21, 2005
Posts: 57
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: static polymorphism v/s dynamic polymorphism
jQuery in Action, 3rd edition