- Ad-hoc polymorphism
- Allow multiple functions that perform an operation on different
add(int, int)
andadd(str, str)
would be separately implemented
- Parametric polymorphism
- This allows a function to deal with generics, and therefore on any concrete definition of the generic.
- e.g. A
List
type in Java, regardless of which objects are in the list
- Subtype polymorphism
- This allows subclass instances to be treated by a function they same way as it would superclass instances
- e.g. Instances of
Cat
will be operated on a function the same way as instances of it's superclassAnimal
.