• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is overloading example of static or dynamic polymorphism

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

i would like to know whether method/operator overloading comes under static polymorphism or dynamic polymorphism....

i request you a detail explanation

thnx......
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For what reason do you want to know? Is there some example code you have questions about?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The term "static polymorphism" has been used to refer to overloading. "static" here means that the decision about which method to call is made when the program is compiled. This is in contrast to "dynamic polymorphism", what you get from overriding methods in Java, in which that decision is deferred until runtime.

But some people -- myself included -- dislike this term "static polymorphism," and prefer to use "polymorphism," without qualification, to mean runtime binding of method calls. The term "overloaded methods" is just fine for overloaded methods, which aren't, IMO, an object-oriented concept.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But then if you override an overloaded method ...
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
polymorphism and overloading are different concepts, not comparable...
 
Ramesh Chandra
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friedman,
Thnx for posting me a detailed solution but i have one doubt regarding overloading in the enduser perspective...

generally our understanding is that in overloading , which method is to be called is decided during compile time... but we are passing the values to these overloaded methods during runtime. depending on the values that we give at runtime the proper method will be invoked...

this sounds like dynamic polymorphism as the method to be invoked is decided during the runtime depending upon the values we pass.

hope u understood my probs
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Friedman!
There is nothing like early binding in java as each method get bind (or get call) at run-time only. In byte (class) file there is'nt any link for any method.

Make me correct if am wrong!

With Best Regards!
Sachin Dimble.
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some points from my side. Please let me know how many are correct:

1] Java doesn't provide user defined operator overloading.

2] Overloading is not an example of polymorphism. It is as good as defining new method, just using the same name.

3] Overridding is the example of polymorphism. Here all games happen. Compiler think something else and JVM execute something else.


[ December 09, 2005: Message edited by: rathi ji ]
 
Sachin Dimble
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi rathi Ji!
According to me..
1] correct
2] Not ok overloading is the kind of polymorphism
3] correct,overriding is also kind of polymorphism.

With Best Regards!
Sachin Dimble.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sachin Dimble:

2] Not ok overloading is the kind of polymorphism



I disagree. Overloading is nothing more than a fa�on de parler.
I can image Java without overloading -- there would have to be a bit of
tweaking to admit multiple constructors, and it would be a bit of a pain
if a latter version of JComponent introduced a method whose name clashed with
one you had introduced in your custom subclass... but by and large Java
would be the same. Now image Java without overriding: it's life, but not
as we know it.

ps. I've been waiting years to drop fa�on de parler into conversation .
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jon Lee:
polymorphism and overloading are different concepts, not comparable...



Polymorphism is often used as a synonym for runtime polymorphism, but historically it actually is a much broader concept, and includes overloading. Search for polymorphism on wikipedia.org (or stupid forum software doesn't allow me to post the link here because of some special characters... :roll: )
[ December 09, 2005: Message edited by: Ilja Preuss ]
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ramesh, Sachin,

try this code:



This should probably be part of our FAQ...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic