Continuing from previous topics
Interface & Components

In this topic describes  How to implement multiple interface in Java?

As known at this point how to write implementation for any single interface ,  in this post lets implement multiple interface, using (,) comma separator for implements keyword we can implement multiple interface

Example:

interface IAddition { 
             int add (int a, int b);
}

interface IDivision { 
             double  divide (int a, int b);
}
 // implementing 2 interface.
class Calculator implements IAddition,  IDivision {

               @Override
               public int add ( int a, int b) {
                      result a + b;
               }

               @Override
               public double divide ( int a, int b) {
                      result a / b;
               }

}

Next topic: How to implement common methods in the Class ?

Advertisements