|
Similar to the top-level class, an interface can either have a public or default access. Therefore, only the access modifier public is applicable to an interface declaration. Since the interface provides no implementation, it is implicitly abstract. For example, in the following code, both the declarations for a public interface Searchable are valid:
public abstract interface Searchable {
}
or
public interface Searchable {
}
No other modifier except the public and abstract can be applied to an interface. When the interface is declared as public, it can be accessed and implemented by any class. The interface without any access modifiers has a default access and is accessible only to the classes (and interfaces) within its package. It also means that only these classes can implement the interface.