It just means that overridden methods may have a slightly different signature than superinterface methods. For instance:
public interface Foo { Object doSomething(String input) throws IOException; } public interface Bar extends Foo { @Override String doSomething(String input); }
As you can see, in the subinterface, I no longer throw a checked exception, and I guarantee that the returned object is a more specific type. The method that throws the checked exception is not inherited because it is overridden.
I don’t have the context of the whole paragraph, but there is something else that applies only to implementations, not to interfaces, which means that if you override the method without explicitly calling super , the superclass implementation will not be executed.
For example, if I have:
public class Example { public static class Foo { public void printSomething() { System.out.println("Foo"); } } public static class Bar extends Foo { @Override public void printSomething() { System.out.println("Bar"); } } public static void main(String[] args) { Bar bar = new Bar(); bar.printSomething(); } }
This program will simply output:
Bar
but NOT Foo . If I add a call to super.printSomething() , it will print both.
source share