File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Whether Overloading is a way to implement Polymorphism? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Whether Overloading is a way to implement Polymorphism?" Watch "Whether Overloading is a way to implement Polymorphism?" New topic
Author

Whether Overloading is a way to implement Polymorphism?

rajiv gupta
Greenhorn

Joined: Jan 04, 2007
Posts: 7
Hi,

There are various ways by which we can implement polymorphism.
Refer: http://www.coderanch.com/t/410123/Java-General-beginner/java/Polymorphism

There are various views of people regarding the type of polymorphism.
Can any one please confirm whether Overloading is a type of polymorphism or not.
If possible, please clarify with any reference link.

I am very much confused about this.

Thanks in advance

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

rajiv gupta wrote:
Can any one please confirm whether Overloading is a type of polymorphism or not.


No. Somebody may refer Overloading is a Compile time polymorphism .
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

seetharaman venkatasamy wrote:
rajiv gupta wrote:
Can any one please confirm whether Overloading is a type of polymorphism or not.


No. Somebody may refer Overloading is a Compile time polymorphism .


I don't see why not? Overloading was always a type of polymorphism (yes - compile time but still polymorphic).
Well at least it was when I was taught OO principles - not sure why there is confusion on this these days?



Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Sam Mercs wrote: Overloading was always a type of polymorphism (yes - compile time but still polymorphic).


As far i know, Polymorphism related to the runtime always
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
I would agree with seetharaman venkatasamy, that polymorphism is determined at run-time using overridden methods. But there are people who talk about compile-time polymorphism with overloading, or even ( ) hiding members.
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Neither method overloading nor method overriding are by themselves implementations of polymorphism. -- Wikipedia

I was also reading up the replies on the other post -- http://www.coderanch.com/t/410123/Java-General-beginner/java/Polymorphism and again its pretty obvious that there is a difference of opinion ...

Well for one polymorphism might also depend on the programming language - for e.g. all javascript functions implicity polymorphic - its a weakly typed language!!

Having said that - I think I'll agree with you folks that in Java - it would be a better idea to refer to polymorphism as run time polymorphism (and no this does not mean over riding - Its got more to do with implementing to interface. Realistically how many methods to we really over ride in 'real world'? - toString and HashCode )

@Rajiv - Sorry if this answer leaves you more confused than before - probably this post is a better place to get the answer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Whether Overloading is a way to implement Polymorphism?