DRAFT
ImplicitInterfaceImplementation
Misconception:
When we state that a class “implements” an interface, this means that Java will automatically generate implementations of all the methods declared in that interface.
Incorrect
Java implicitly produces implementations of any methods a class inherits from the interfaces it implements
Correct
CorrectionHere is what's right.
Here is what's right.
The word “implements” means that we, the author of the class, have to provide those implementations.
interface I {
public abstract void m1();
public abstract void m2();
}
class C implements I {
}
The above code won’t compile. We have to provide the implementations ourselves:
interface I {
public abstract void m1();
public abstract void m2();
}
class C implements I {
public void m1() { /* our implementation */ }
public void m2() { /* our implementation */ }
}