Files
javalab/P3.java
2023-06-05 00:09:49 +05:30

28 lines
477 B
Java

interface Animal {
void makeSound();
}
class Cat implements Animal {
@Override
public void makeSound() {
System.out.println("Meow!");
}
}
class Cow implements Animal {
@Override
public void makeSound() {
System.out.println("Moo!");
}
}
public class P3 {
public static void main(String[] args) {
Animal cat = new Cat();
Animal cow = new Cow();
cat.makeSound();
cow.makeSound();
}
}