问题
问答题
按以下要求编写程序
(1) 编写Animal接口,接口中声明run______ 方法
(2) 定义Bird类和Fish类实现Animal接口
(3) 编写Bird类和Fish类的测试程序,并调用其中的run______方法
答案
参考答案:public interface Animal {
void run______;
}
class Bird implements Animal {
public void run______ {
System.out.println("鸟儿在飞...");
}
}
class Fish implements Animal {
public void run______ {
System.out.println("鱼儿在游...");
}
}
public class TestAnimal {
public static void main(String[] args) {
Bird bird = new Bird______;
bird.run______;
Fish fish = new Fish______;
fish.run______;
}
}