选择题
- D
- C
- B
- C
- A
- BD
- A
案例题
使用接口的知识, 定义接口IFly,创建三个类Plane类、Bird类、Balloon类,分别重写接口中的fly( )
方法,然后再测试类中进行调用。
IFly接口
public interface IFly {
public void fly();
}
Plane类
public class Plane implements IFly {
@Override
public void fly() {
System.out.println("飞机在天上飞");
}
}
Brid类
public class Bird implements IFly {
@Override
public void fly() {
System.out.println("小鸟在天空翱翔");
}
}
Ballon类
public class Balloon implements IFly {
@Override
public void fly() {
System.out.println("气球在天空飞");
}
}
测试类
public class Test {
public static void main(String[] args) {
IFly plane = new Plane();
plane.fly();
IFly bird = new Bird();
bird.fly();
IFly balloon = new Balloon();
balloon.fly();
}
}