+ 2
what is method overriding?
3 Respostas
+ 2
here is an example that you may want to check to see difference or understand the meanings of overriding and overloading https://code.sololearn.com/c0awDMpDLukF/?ref=app
+ 1
overriding a method is used when a class needs to utilize a parent classes method in a different way.
Example, third class has a method that prints the statement hi. The second class needs the third class for something but it needs the method to say hello instead of hi. you extend the class, add the method but in the body you put the new println. The SecondClass has now overridden the third classes print method.
0
overriding is performed in different class whereas overloading is performed in same class in overriding rules
method must have same name as in super class
and parameters
must be is-a relationship (inheritance)