凤凰求蛊
你好,标准答案是这样的:abstract class Animal {public abstract void eat();}class Rabbit extends Animal {public void eat() {System.out.println("我吃草");}}class Monkey extends Animal {public void eat(){System.out.println("我吃香蕉");}}class Tiger extends Animal {public void eat(){System.out.println("我吃肉");}}class Boy{public void feed(Animal animal){animal.eat() ;}}public class TestAnimal {public static void main(String[] args) {Animal animal1 = new Rabbit() ;Animal animal2 = new Monkey() ;Animal animal3 = new Tiger() ;Boy boy = new Boy() ;boy.feed(animal1) ;boy.feed(animal2) ;boy.feed(animal3) ;}}