views:

455

answers:

8

Is Method Overloading considered part of polymorphism?

Thank you very much.

+1  A: 

Strictly speaking polymorphism, from wikipedia:

is the ability of one type, A, to appear as and be used like another type, B.

So, method overloading as such is not considered part of this definition polymorphism, as the overloads are defined as part of one type.

If you are talking about inclusion polymorphism (normally thought of as overriding), that is a different matter and then, yes it is considered to be part of polymorphism.

inclusion polymorphism is a concept in type theory wherein a name may denote instances of many different classes as long as they are related by some common super class.

Oded
+8  A: 

No, overloading is not. Maybe you refer to method overriding which is indeed part of polymorphism.

To further clarify, From the wikipedia:

Polymorphism is not the same as method overloading or method overriding.1 Polymorphism is only concerned with the application of specific implementations to an interface or a more generic base class.

So I'd say method overriding AND method overloading and convenient features of some language regarding polymorphism but notthe main concern of polymorphism (in object oriented programming) which only regards to the capability of an object to act as if it was another object in its hierarchy chain.

Jorge Córdoba
+6  A: 

There are different types of polymorphism:

  • overloading polymorphism (also called Ad-hoc polymorphism)
  • overriding polymorphism

So yes it is part of polymorphism.

Darin Dimitrov
You need to mention, that "This section's factual accuracy is disputed" so it is not yet stated 100% that overloading is polymorphism as I understand.
FractalizeR
@FractalizeR maybe your understanding is limited to runtime polymorphism in object oriented languages, not the term in general
Pete Kirkham
I am just citing WikiPedia here ;)
FractalizeR
+2  A: 

no, overriding is, overloading is something different

jk
A: 

It's a necessary evil that is and should only be used as a complement. In the end overloads should only convert and eventually forward to the main method. OverloDing is necessary because most vms for staticalky dispatched environments don't know how to convert one type to another so the parameter fits the target and this is where one uses overloads to help out.

 StringBuilder
     Append(String) // main
     Append(Boolean) // converts and calls append(String)
mP
+1  A: 

There are 2 types of polymorphism.

  1. static
  2. dynamic.

Overloading is of type static polymorphism.. overriding comes under dynamic (or run-time) polymorphism..

ref. http://en.wikipedia.org/wiki/Polymorphism_(computer_science) which describes it more.

echo
A: 

Well polymorphism is determining at runtime what to call .So is method overloading

mazhar kaunain baig
For C# and other compiled languages, method overloading is fully determined at compile time. There is no runtime determination.
dthorpe
A: 

Wikipedia pedantics aside, one way to think about polymorphism is: the ability for a single line of code / single method call to do different things at runtime depending on the type of the object instance used to make the call.

Method overloading does not change behaviors at runtime. Overloading gives you more choices for argument lists on the same method name when you're writing and compiling the code, but when it's compiled the choice is fixed in code forever.

Not to be confused with method overriding, which is part of polymorphism.

dthorpe