Polymorphism explained with real world example in Java

preview_player
Показать описание
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOPS occurs when a parent class reference is used to refer to a child class object. Polymorphism is a Greek word. poly means “many” and morphs means “forms”.
There are two types of polymorphism. They are
1. Compile-time polymorphism
2. Run-time polymorphism

Method overloading is the called as the compile time polymorphism. Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different. It is similar to constructor overloading in Java, that allows a class to have more than one constructor having different argument lists.

In runtime polymorphism, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable.
Рекомендации по теме
Комментарии
Автор

Argument is the "value" passed to a method...the method has parameters receiving "Arguments"...

dominiquez
Автор

The strongest South Indian accent I ever heard :)
Very good explanation and loved the energy man! thanks.

tamalanwar