aspose file tools*
The moose likes Beginning Java and the fly likes Polymorphism in java??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Polymorphism in java???" Watch "Polymorphism in java???" New topic
Author

Polymorphism in java???

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi all,


Does java support both runtime as well as compile time polymorphism

..as in C++?


Tx
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Yes.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
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

Joined: Jul 11, 2001
Posts: 14112
Originally posted by A Kumar:
like overriding..runtime polymorphism..


Correct!


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


Overloading.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thanks Ilja....
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You're welcome!
Kudret Serin
Ranch Hand

Joined: Aug 02, 2005
Posts: 167

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
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

Joined: Sep 20, 2003
Posts: 1704
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

Joined: Jul 04, 2004
Posts: 979


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

Joined: Jul 11, 2001
Posts: 14112
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

Joined: Mar 25, 2005
Posts: 87
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

Joined: Jul 04, 2004
Posts: 979
Thanks Ilja...!!!
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I'm glad it helped!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Polymorphism in java???