7.Program to demonstrate interface in java program.
interface Shape {
double calculateArea(); // Abstract method
}
class Circle implements Shape {
private double radius;
public Circle(double radius) {
this.radius = radius;
}
@Override
public double calculateArea() {
return Math.PI * radius * radius;
}
}
public class InterfaceDemo {
public static void main(String[] args) {
Circle circle = new Circle(5); // Create a Circle object
System.out.println("Area of the circle: " + circle.calculateArea()); // Call the method from the interface
}
}