Home » Programming » 09 - Object Oriented Programming Concepts
9

Polymorphism

Polymorphism is the ability of object oriented programming languages to use a single definition, procedure, or task on multiple data objects or classes.

Polymorphism is the ability of object oriented programming languages to use a single definition, procedure, or task on multiple data objects or classes. If object B inherits the properties of object A then both of them can take advantage of similar procedures.

Inheritance and polymorphism are pretty much related. This time, instead of inheriting the characteristics, think about tasks and capabilities. If people eat and sleep then boys and girls must be able to eat and sleep too. If object A can do task 1 then object B can do task 1 as well.

Take note of certain things though. If boys, girls, and people can eat and sleep, can all the animals do it too? Boys can do things that girls can't and girls can do things that boys can't. People can think and reason but can amphibians think and reason? Take note of these peculiarities because you will need to think this way when you are programming. Some object may inherit some traits but will be unable to do certain tasks.