Why We Use Override?
@Override @Override Annotation Informs the Compiler That the Element Is Meant to Override an Element Declared in a Superclass. Overriding Methods Will Be...
@Override @Override annotation informs the compiler that the element is meant to override an element declared in a superclass. Overriding methods will be discussed in Interfaces and Inheritance. While it is not required to use this annotation when overriding a method, it helps to prevent errors.
Why do we use the @override in our code?
Why we use @Override annotation
As by using this annotation you instruct compiler that you are overriding this method. If you don't use the annotation then the sub class method would behave as a new method (not the overriding method) in sub class. 2) It improves the readability of the code.
Must Read
Why do we use override in Java?
The purpose of Method Overriding is that if the derived class wants to give its own implementation it can give by overriding the method of the parent class. When we call this overridden method, it will execute the method of the child class, not the parent class.