All about interfaces
constants = public, static, final
methods = public, abstract
top - level interfaces = public, abstract
interfaces within interfaces = public, static, abstract
classes within interfaces = public, static, abstract, final
interfaces within classes = public, protected, private, static, abstract
Constants in interfaces are implicitly static? Any logical reason?
Constants in interfaces can be hidden by subinterfaces. In the case of multiple inheritance of interface constants any name conflicts can be resolved using fully qualified names in the constants involved.
interface X {
int c =10;
}
interface Y extends X {
int c =20;
}
class A implements Y {
public static void main(String[] args) {
System.out.println(c); // 20
System.out.println(X.c); // 10
}
}
interfaces can only declare constants and not instance variables.
A member interface is an interface that is a member of some other class (or) interface and yes member interface are implicitly static. Any logical reason for this?
Mostly because there is no real use for a "this" reference inside an interface, so there's no benefit to having a non static interface.
0 Comments:
Post a Comment
<< Home