• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whether Overloading is a way to implement Polymorphism?

 
rajiv gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic