Write overridden methods to change behavior of inherited methods.
Use super to access superclass methods.
Identify applications of polymorphism in method and function use.
Overriding methods
Sometimes a programmer wants to change the functions a subclass inherits. Mint is a subclass that has the same functionality as Plant, except for one function. A subclass can override a superclass method by defining a method with the same name as the superclass method.
super
super is a special method that provides a temporary superclass object instance for a subclass to use. super is commonly used to call superclass methods from a subclass. super is commonly used in a subclass's __init__ to assign inherited instance attributes. Ex: super.__init__.
Polymorphism
Polymorphism is the concept of having many forms. In programming, a single name can be used for multiple functionalities. Within inheritance, polymorphism is the basis of method overriding, as multiple methods have the same name.
Polymorphism can also be used with methods of unrelated classes. The class type of the calling object determines the method executed.
Polymorphism allows methods to be called with different parameter types. Many built-in operators and functions have this utility.