0
Polymorphism and overriding
Help, I cannot recognize difference between Polymorphism and Overriding. Examples in java tutorial look just like same. What is the differrence between them?
1 ответ
+ 1
POLYMORPHISM is of two types , Function overloading that is also called method overloading and second is Method Overriding.
In FUNCTION OVERLOADING, Methods have same name with different number of arguments or with different data types also.
In METHOD OVERRIDING, Methods have same name with same number of arguments.
METHOD OVERRIDING is only achieved by Inheritance and Interfaces.
EXTRA CONCEPT OF METHOD OVERRIDING:
------------------------------------------------------------------------
Whenever methods parent has by default available to the child through inheritance sometimes child class may not satisfy with the parent method implementation. Then the child class is allow to redefine that method based on its own requirement. This process is called overriding.
The parent class method is overridden is called overridden method.
The child class method which is overriding is called overriding method.