class Animal {
void Eat(){};
void Sleep(){System.out.println("睡觉一样!");}
}
class Rabbit extends Animal{
void Eat(){
System.out.println("Rabbit是吃草的!!");
}
super.Sleep();
/*void Sleep(){
//System.out.println("睡觉一样!");
}*/
}
class Tiger extends Animal{
void Eat(){
System.out.println("Tiger是吃肉的!!");
}
super.Sleep();
/*void Sleep(){
//System.out.println("睡觉一样!");
}*/
}
class AnimalTest{
public void Test(){
Animal a=new Rabbit();
a.Eat();a.Sleep();
Animal b=new Tiger();
b.Eat();b.Sleep();
}
}
public class LianXi32{
public static void main(String[] args){
AnimalTest r=new AnimalTest();
r.Test();
}
}
怎么调用不了父类中的Sleep方法啊??? |