Method overriding allows a subclass to provide a specific implementation of a method already provided by its superclass.
Source Code
class Animal {
void speak() {
System.out.println("The animal speaks");
}
}
class Dog extends Animal {
@Override
void speak() {
System.out.println("The dog barks");
}
}