JAVA RECORD PROGRAM TO UNDERSTAND MULTIPLE INTERFACE

 // 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

JAVA RECORD PROGRAM FOR FIBBONACCI SERIES

JAVA RECORD PROGRAM FOR AREA AND PERIMETER OF RECTANGLE

JAVA RECORD PROGRAM FOR MATRIX MULTIPLICATION