• 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

Polymorphism in java???

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


Does java support both runtime as well as compile time polymorphism

..as in C++?


Tx
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

can u tell me the specific ways they come into picture....

like overriding..runtime polymorphism..

then static/compile..time polymorphism.. where??

Tx
[ August 23, 2005: Message edited by: A Kumar ]
 
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

Originally posted by A Kumar:
like overriding..runtime polymorphism..



Correct!


then static/compile..time polymorphism.. where??



Overloading.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ilja....
 
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
You're welcome!
 
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ilja,

Can you have a look at the below URL .here he says that


overloading is assosciated with late binding...

http://www.janeg.ca/scjp/overload/poly.html

Can you clear the matter??

Tx
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by A Kumar:
Hi Ilja,

Can you have a look at the below URL .here he says that


overloading is assosciated with late binding...

http://www.janeg.ca/scjp/overload/poly.html

Can you clear the matter??

Tx



Late binding is some thing which will be decided during run time. In overloading the method name will be same but we can pass different parameters. Based on the parameters we passed the processor will decide which method is matching. This is called late binding.

Were as in Early binding the methods are decided during compile time itself which is faster as compare to late binding.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Late binding is some thing which will be decided during run time. In overloading the method name will be same but we can pass different parameters. Based on the parameters we passed the processor will decide which method is matching. This is called late binding.



quote:

then static/compile..time polymorphism.. where??



Overloading.






If u consider what is given in the URL page and what was Iljas post...

does overloading qualifies for both compile time as well as late binding

(run time) polymorphism..

Regards
 
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
That page is *wrong* - Java doesn't use late binding for overloading, but only for overriding!

Take the following example code:



If Java used late binding for overloading, the above should print "integer: 42", but it does print "number: 42" - the method to call is decided at compile time based on the type of the variable, not at runtime based on the type of the object.

Hope this helps...
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
waw.
Iija..
thanx for that clarification even i was following this thread acrefully!!
got new concept from that thanx!!!
thanx once again!!
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ilja...!!!
 
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
I'm glad it helped!
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic