Polymorphism and Abstraction

Polymorphism and Abstraction

Polymorphism, from Greek roots meaning "many forms," is the ability of a single interface or name to work with objects of different types, each responding in its own way. Together with abstraction — the practice of exposing only essential features while hiding detail — it gives object-oriented programs much of their flexibility and elegance. This lesson distinguishes the two forms of polymorphism and introduces the abstract types that make polymorphism powerful.

Overloading vs overriding

There are two related but distinct mechanisms that both let one method name serve multiple purposes.

Method overloading defines several methods with the same name but different parameter lists (different number, types, or order of parameters) within the same class. The compiler chooses which one to call ba