Polymorphism is one of the four pillars of oops and means to take more than one form. An ability to create multiple functions with the same name. Polymorphism can help us to create consistent code.
public interface Food{}
public class Fruit{}
public class Mango extends Fruit implements Food {}
It can be obtained by function overloading or operator overloading. Method Overloading: An ability to create multiple functions with the same name but different parameters. Functions can be overloaded by modifying the number of arguments or/and modifying the type of arguments.
A function calls to the overridden method at run time can be resolved. It can be obtained by Method Overriding.
Method overriding happens when a derived class has a definition for one of the member functions of the base class.
Programming Knowledge2life
Knowledge2life1
Knowledge2life2
Knowledge2life3
|