This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Polymorphism in java???

 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


Does java support both runtime as well as compile time polymorphism

..as in C++?


Tx
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Ilja....
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • 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
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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...
 
Ashok George
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Ilja...!!!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad it helped!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic