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 need to be implemented.
The word polymorphism originates from the Ancient 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...