Introduction to polymorphism
The term polymorphism applies to many scientific and mathematical concepts, but the meaning is generally the same across all definitions. It refers to the ability to change into many different forms, and when it comes to OOP, it refers to changes that are made to classes and members that transform into something different that may deviate from their original form. This can be a powerful tool to encourage code reuse and create many types of objects that come from the same base class. Polymorphism can be grouped into two forms: static and dynamic.
Static polymorphism
Static polymorphism refers to methods that are determined at runtime, or code that is compiled before the program begins execution. One example of static polymorphism is method overloading, where two methods with the same name are created but have different parameters. The following example shows an example of overloading, where a decision has been made to round all future payments up to...