• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Polymorphism & overloading

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic