14)Write a program to demonstrate the usage of interfaces.

PHOTO EMBED

Mon Jul 08 2024 06:11:29 GMT+0000 (Coordinated Universal Time)

Saved by @varuntej #java

// Interface
interface Printable {
    void print();
}

// Class implementing the interface
class Printer implements Printable {
    @Override
    public void print() {
        System.out.println("Printing...");
    }
}

public class InterfaceExample {
    public static void main(String[] args) {
        // Creating an instance of the class implementing the interface
        Printable printer = new Printer();

        // Using the interface method
        printer.print();
    }
}
content_copyCOPY