Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Polymorphism & overloading

 
Marium Hasan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello
I had a problem.
there is a question?
Is overloading an example/type of Polymorphism?
i have tried a simulator (jxam) & the options were:
1) overloading
2) overriding
2,3 & 4 th options were not correct , I have checked overriding
but the answer was overloading.
Also, i have study in the notes of Velmurugan of it that
Overloading is an example of Poly.
What is the truth?
Plz help , its urgent
Marium
 
Manish Hatwalne
Ranch Hand
Posts: 2595
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
polymorphism means "many forms". Overloading definitely is an example of (static) polymorphism, as one function can take many form. But, overriding is also dynamic polymorphism AFAIK. But I have seen notes saying that *only* overloading is polymorphism, which beats me.
I suggest you post this to "Programmer Certfication Study" forum, you are most likely to get correct answer there.
- Manish
 
Manish Hatwalne
Ranch Hand
Posts: 2595
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did little research (google of course!!!).
Overriding is polymorphism, in fact more so compared to overloading, which is also known as ad hoc polymorphism. Here's the link - http://www.cs.olemiss.edu/~hcc/softArch/notes/budd12.html
But then, if you have to choose only one as a correct answer, which one you'll choose? I'll go for overriding.
- Manish
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Overriding replaces the overridden method from the superclass with another method with the same argument signature and return type. That is, it's a new method that is using the skeleton of the old method - you can even use part of the old method by calling super()
Overloading on the other hand is a completely new method that uses the same name - with different argument signature and possibly return type - for the programmers convenience. There is no connection between the two methods.

Hope that helps,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there is some debate about the terminology. In my opinion, if there is no late binding (as in over-riding) it is NOT polymorphism. But not everyone shares that definition.
Here is a debate that we had some time ago on that very subject: http://www.javaranch.com/ubb/Forum24/HTML/009465.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic