Polymorphism
After encapsulation and inheritance, polymorphism is seen as the third pillar of object-oriented programming. It decouples the "what" from "how" at the type level. One of the advantages that polymorphism offers is improved code organization and readability; furthermore, it allows you to extend your programs at any point later, when new features are required to be implemented.
The word polymorphism originates from the Greek language: polys (πολύς), meaning many or much and morphē (μορφή), meaning form or shape. There are multiple forms of polymorphism, but in this chapter, we are going to talk about the one known as late-binding (or dynamic binding or runtime binding).
The power of polymorphism comes at runtime when objects of a derived class are treated as objects of the base class. This can happen for a method parameter or when it comes to storing a group of common elements in a collection or array. The peculiar thing here is that the object's declared type will not be identical...