Interface

To over ride met1() and met2() methods from different classes in one class, you need to inherit class A and class B. But multiple inheritance is not allowed in Java. That’s where you need to use interface.

An interface is like a class but having all methods as public and abstract and all variables as static, public and final.
A class can extend only one class but can implement multiple interfaces.
Any class implementing an interface should override all the methods of that interface.

interface A
{
    public void met1();
}
interface B
{
    final int x = 10;
    public void met2();
}
class Interface1 implements A, B
{
    public void met1()
    {
        System.out.println("met1 in Interface1");
    }
    public void met2()
    {
        System.out.println("met2 in Interface1");
    }
    public static void main(String args[])
    {    System.out.println(B.x);    }
}

OUTPUT : 10