Thursday, 4 September 2014

JAVA Implement Multiple Interface

package com.mastermoin.ICore;

public interface InterfaceOne {
       void methodFromInterfaceOne();
}

________________________________________________________________________

package com.mastermoin.ICore;

public interface InterfaceTwo {
       void methodFromInterfaceTwo();
}
________________________________________________________________________ 

package com.mastermoin.java;

import com.mastermoin.ICore.InterfaceOne;
import com.mastermoin.ICore.InterfaceTwo;

public class DemoRun implements InterfaceOne,InterfaceTwo{

       public static void main(String[] args) {
              DemoRun obj = new DemoRun();
              obj.methodFromInterfaceOne();
              obj.methodFromInterfaceTwo();
       }

       @Override
       public void methodFromInterfaceTwo() {
              System.out.println("From Interface Two");
             
       }

       @Override
       public void methodFromInterfaceOne() {
              System.out.println("From Interface One");
             
       }
}
 __________________________________________________________________________
Output

From Interface One
From Interface Two

No comments:

Post a Comment