Below are some of the golden rules or facts about java interfaces where most of the developers do not make use or may be unaware of the same.
1. This rule is the very basic one that every developer must know. All the fields of an interface are public, static & final by default.
2. In any interface, the methods declared are public by default.
3. Any non-abstract classes has to override all the methods declared in the super interface.
Note : The Car class (non abstract class) will throw a compilation since it does not provide implementation for all the methods declared in the Vehicle interface.
4. An interface can never extend any class.
5. Nesting of interface is well supported in java.
6. Methods in an interface cannot be declared as static and final.
7. The concept of functional interface is an interesting one in java. A functional interface is nothing but an interface with only one method.
8. Marker interface is an interface with no methods declared. E.g. Serializable interface in java.
9. An interface can also be nested under a class.
Questions? Comments? Suggestions? Let us know!! Like / Subscribe / Follow for more updates.