Polymorphism explained with real world example in Java

InvolveInInnovation
InvolveInInnovation
16.4 هزار بار بازدید - 6 سال پیش - Polymorphism is the ability of
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.
6 سال پیش در تاریخ 1397/08/28 منتشر شده است.
16,465 بـار بازدید شده
... بیشتر