Write a Java program to create an interface Drawable with a method draw() that takes no arguments and returns void. Create three classes Circle, Rectangle, and Triangle that implement the Drawable interface and override the draw() method to draw their respective shapes.

Source Code:

interface Drawable {
void draw();
}

class Circle implements Drawable {
public void draw() {
System.out.println(“Drawing Circle”);
}
}

class Rectangle implements Drawable {
public void draw() {
System.out.println(“Drawing Rectangle”);
}
}

class Triangle implements Drawable {
public void draw() {
System.out.println(“Drawing Triangle”);
}
}

public class TestDraw {
public static void main(String[] args) {
Drawable c = new Circle();
Drawable r = new Rectangle();
Drawable t = new Triangle();
c.draw();
r.draw();
t.draw();
}
}

Output: