You can download the code and have a play with it. Polymorphism Polymorphism is one of the three fundamental principles in object oriented programming. The other two are encapsulation and inheritance. Of the three, I would say polymorphism is the hardest to comprehend. To learn polymorphism, you should understand inheritance.
Inheritance is a mechanism that allows a class to be defined as a specialization of another class.
It is said that the more specialized class is a subclass or a child class of the more general class. The class where the child class is derived from is also called the parent class. Inheritance gets its name because the subclass inherits all the properties and methods from the parent class, except those that are private to the parent class. When dealing with class hierarchies, you often want to treat an object not as the specific type that it is, but instead as its base type. This allows you to write code that doesn't depend on specific types.