OCAJP | Interfaces
Use Interfaces Declaring an interface : When you create an interface, that means you are defining a prototype of class, that what a class can do. In other words we can say interface is pre-declaration of class. Rules for defining an interface : 1. All methods of an interface are implicitly public & abstract whether you declare or not. 2. All variables of interface must be public , static, or final i.e., we can declare only constants but not variables. 3. Interface methods can’t be static. 4. Because interface methods are abstract , so it can’t be final,strictfp or native. 5. Interface can extend one or more other interfaces. 6. Interface can’t extend anything other than interface. 7. Interface can’t implement any class or other interface. 8. Interface must be declared with the keyword interface. Some legal declaration of interface : 1. public abstract interface Boun...