AnswerBox
Java

Interface Example

Description:
Demonstrate Java interfaces with Animal example.
Java Code
interface Animal { void sound(); }

class Dog implements Animal {
    public void sound() { System.out.println("Dog: Woof!"); }
}
class Cat implements Animal {
    public void sound() { System.out.println("Cat: Meow!"); }
}

public class InterfaceDemo {
    public static void main(String[] args) {
        new Dog().sound();
        new Cat().sound();
    }
}
Expected Output
Dog: Woof! Cat: Meow!