JAVA RECORD PROGRAM TO UNDERSTAND MULTIPLE INHERITANCE

 // Define two interfaces

interface Interface1 {

    void method1();

}


interface Interface2 {

    void method2();

}


// Implement both interfaces in a single class

class MyClass implements Interface1, Interface2 {

    @Override

    public void method1() {

        System.out.println("Implementation of method1");

    }


    @Override

    public void method2() {

        System.out.println("Implementation of method2");

    }

}


public class Main {

    public static void main(String[] args) {

        // Create an instance of MyClass

        MyClass myClass = new MyClass();


        // Call methods from both interfaces

        myClass.method1();

        myClass.method2();

    }

}


Comments

Popular posts from this blog

PROGRAM FOR BANKERS ALGORITHM FOR DEADLOCK AVOIDENCE

JAVA RECORD PROGRAM FOR AREA AND PERIMETER OF RECTANGLE

JAVA PROGRAM TO PERFORM MULTI THREADING USING RUNNABLE INTERFACE