0
polymorphism Vs method overriding
how is polymorphism different from method overriding?
3 Antworten
+ 1
polymorphism is the concept of substituting different objects in code, the fact that an overarching type can have potentially multiple forms. Method overriding is one of the ways this is achieved, which gives the objects their different behavior
0
Method overriding is (or can be) part of polymorphism.
0
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.