How to override Java Methods
Overriding java methods happen in a case where a child class implements a method that is contained in super class.The main use of overriding is to provide a new implementation of a method.
Overriding Java methods can take place if only:-
- Child class and parent class are in IS-A inheritance.
- Child class method should have the same name as parent class.
- Child class method should have the same parameters as the parent class.
Overriding Java methods Example