+ 12
What is method overriding in java?
3 Answers
+ 12
Added a little example for you at the playground:
https://code.sololearn.com/c5pdVuw8Nmpe/?ref=app
Hope it helps...
+ 10
A method that is defined differently in a derived class than in the super class, but has the same declaration (but adding @Override annotation to method of the derived class).
Simplest example:
toString method. Try to print an object, when toString is not overridden. It will print the default toString of object (class name @ hashcode).
If you override toString in your class, you can choose how it's gonna be printed. Any String return value is possible. During runtime it will be checked, if you overrode the method and use the overridden one if you call toString.
+ 1
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