Prateek Prateek - 2 months ago 13
Java Question

Can an interface extend multiple interfaces in Java?

Can an

interface
extend multiple interfaces in Java?

Answer

Yes, you can do it. An interface can extends multiple interfaces.

interface Maininterface extends inter1, inter2, inter3{  
  // methods
}

Not only interfaces,A single class can also implement multiple interface. Then obviously a doubt raises, what if two interfaces have a method both with same name and signature.

There is a tricky point:

interface A
{
    void test();
}

interface B 
{
    void test();
}

class C implements A, B
{

    @Override
    public void test() {

    }     

}

Then single implementation works for both :).

Read my complete post here:

http://codeinventions.blogspot.com/2014/07/can-interface-extend-multiple.html