Java program for Interface
KW.java
interface Operations
{
    interface add
    {
        void add(int x,int y);
    }
    interface sub
    {
        void sub(int x,int y);
    }
}

class KW implements Operations
{
    void add(int x,int y) 
    {
        System.out.println("Addition "+(x+y));
    }
    void sub(int x,int y) 
    {
        System.out.println("Subtraction "+(x-y));
    }
    public static void main(String[] args) 
    {
        KW k=new KW();
        k.add(10,20);
        k.sub(20,10);
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Addition 30 Subtraction 10 kodingwindow@kw:~$
Advertisement