Course Object Oriented Programming

Polymorphism Subtyping

Course's Page 14 min Text by
User Image
Abacate

Hello, in this class we will learn about polymorphism SubType.

What is it?

Polymorphism Subtype occurs when objects derived from the same class do the same action in different ways.

Remembering then the example of how animals emit sounds. The cat meow, the dog barks, the wolf howls and the bear roars. These are all animals but they perform the action of emitting sounds in different ways.

Polymorphism then tries to represent this kind of situation.

Overwritten

The overwriting of methods is a concept that allows us to rewrite methods initially created in the base class.

Overwritten methods must always have the same:

  • Type of return
  • Parameters

However, they may have different implementation.