on Dan Chrisholm's mock exam on interfaces:
http://www.danchisholm.net/oct1/mybook/chapter10/exam1.html in question 16:
interface A {void m1();} // 1
class B implements A {public void m1() {}} // 2
class C implements A {protected void m1() {}} // 3
class D implements A {private void m1() {}} // 4
class E implements A {void m1() {}} // 5
Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
e. 5
The answer is c,d,e. But I think, that line 2 also generates an error, as the curly brackets mean that one is implementing the method.
<br><br>
In case of extrending abstract class, you can override a method with protected access if the abstract class is having with default access, and override it as public access if abstract class is having it with the protected access. But you can't do this in case of interfaces, Becauae as
you should know, all the methods of an interface are implicitely public and abstract. So public can't be overridden with less access visibility.
public(LY) accessible method can only be overridden using public access modifier, because the super class promises to be so, therefore the subclass can't make it less visible (breaking the contract).
cmbhatt