Polymorphism
Polymorphism allows a programmer to specialize functionality based on a context; the programming language will use the proper version. There are two main types of polymorphism:
- Compile-time (static) polymorphism: Also known as method overloading or compile-time method dispatch, this type of polymorphism occurs when different methods or functions have the same name but different parameter lists. The decision on which method to call is made at compile time based on the number and types of arguments provided. This allows you to have multiple methods with the same name but different behaviors based on the input parameters.
- Runtime (dynamic) polymorphism: Also known as method overriding or runtime method dispatch, this type of polymorphism occurs when a subclass provides a specific implementation of a method already defined in its superclass (or an interface). At runtime, the method call is resolved to the subclass implementation if the object referenced is an instance...