What are the modifiers can have interface ?




What are the modifiers can have interface ?

  • Interface are used in the java language. Java does not support multiple inheritance. So, that java used the interface.
  • Java can have only one modifier which is public. No other modifiers (private and protected) are allowed within an interface neither with fields nor with any methods.
  • Obviously among the modifiers, private has no meaning to use within an interface but protected should be allowed within an interface. Because it can be incorporated by it's implementing class.

Read Also

Sample Code

interface Demo
{
    private final static int a=10; 
      //Will not be compiled.
    protected final static int b=20; 
      //Will not be compiled.
    public final static int x=0;   
      //ok

    abstract public void showSum();
}


Related Searches to What are the modifiers can have interface ?