jargon

Comparison

Method overloadingvsMethod overriding

Method overloading

there are four methods with the same name and different parameters, and the compiler picks one before the program ever runs.

Several methods sharing a name and distinguished by their parameter lists, resolved at compile time by the static types of the arguments. It has nothing to do with overriding despite the similar word, and confusing the two is the single most common slip in an interview answer about polymorphism. It is also a quiet source of bugs when an argument's declared type differs from its runtime type and the overload chosen is not the one you pictured.

Full entry →

Method overriding

the subclass replaces the parent's version of a method, and every existing caller silently starts getting the new one.

Providing a subclass implementation of a method the parent already defines, so calls through the parent's type reach the child's version. It is the primary extension point of inheritance and the primary way inheritance goes wrong, because the parent's other methods may call the one you replaced and assume the old behaviour. This is what the Liskov substitution principle is about, and what makes overriding a stronger commitment than it looks.

Full entry →

Related comparisons