Some Useful Rules For Interface

As I found some Rules for Java Interfaces, which is very useful for any java programmer, I am publishing it here. If you have some more idea please do send me.

The rules go like this:

  • The entire interface is implicitly public and abstract. That means, we do not need to type public or abstract modifier in the member methods.
  • All variable defined in a interface must be public, static, and final. That means, interface can define only constant not instance variable.
  • Interface method must not be static.
  • As interface methods are abstract, they cannot be marked final, strictfp, or native.
  • An interface can extend one or more other interfaces.
  • An interface cannot extend anything but another interface.
  • An interface cannot implement another interface or class.
  • An interface must be declared with the keyword interface.
  • Interface types can be used polymorphically