This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Polymorphism & overloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Polymorphism & overloading" Watch "Polymorphism & overloading" New topic
Author

Polymorphism & overloading

Marium Hasan
Greenhorn

Joined: Oct 03, 2001
Posts: 12

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

Joined: Sep 22, 2001
Posts: 2578

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

Joined: Sep 22, 2001
Posts: 2578

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

Joined: May 30, 2001
Posts: 328
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


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
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


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Polymorphism & overloading
 
Similar Threads
Method Overloading and overriding
Polymorphism
Simple Question
overriding and polymorphism
Polymorphism