定义一个接口类
//接口
interface interface4 {
public abstract void fly();
public abstract void eat();
}
//定义一个老鹰类
public class interface3 implements interface4{
public void fly(){
System.out.println(“我是老鹰,我会飞”);
}
public void eat(){
System.out.println(“我是老鹰,我吃兔子”);
}
}
//定义一个麻雀类
class interface2 implements interface4{
public void fly(){
System.out.println(“我是麻雀,我会飞”);
}
public void eat(){
System.out.println(“我是麻雀,我吃虫子”);
}
}
//定义一个鸵鸟类
class interface1 extends interface2 {
public void fly(){
System.out.println(“我是鸵鸟,我不会飞”);
}
}
定义一个测试类
public class test01 {
public static void main(String[] args){
interface3 laoying =new interface3();
laoying.fly();
interface1 tuoniao=new interface1();
tuoniao.fly();
}
}