Originally posted by Tony kunds:
my question is why can't it be default?
From the JLS,
§9.1.4 Access to Interface Member Names:
All interface members are implicitly public.
Therefore, it would be illegal to implement a method required by an interface as default because that would make the method "less visible" than the original method, which is not legal in
Java.
2)in what cicumstances can an interface be private or protected?
Again, from the JLS,
§9.1.1 Interface Modifiers:
The access modifiers protected and private pertain only to member interfaces within a directly enclosing class declaration (�8.5) and are discussed in �8.5.1.
So protected or private interfaces are only involved when an interface is nested within another class. Check out those other sections of the JLS if you need more details about this.
3)Abstract classes can have constructors why can't interfaces have constructors,when both canot be instantiated.
Don't forget that an abstract class can have member variables of its own that are then inherited by any subclasses. Because of this, initialization of those members may be required, which requires a constructor.
An interface, on the other hand, has only static members, which requires no constructor.
I hope that helps answer most of your questions,
Corey