When a subclass provides its own version of a method that its superclass already defines, that is method overriding.
A subclass can override a public method from its superclass by writing a method with the exact same method signature (name and parameters). To indicate that you are overriding a method, put @Override before the method in the subclass. While this isn’t necessary, it is important for preventing errors and code clarity. When you call that method on a subclass instance, Java uses the subclass’s version. In the example below, the method speak() is being overridden: