class Cat{
public void eat(){
System.out.println("猫吃猫粮");
}
public void catchMouse(){
System.out.println("抓老鼠");
}
}
class Dog extends Cat{
public void eat(){
System.out.println("啃骨头");
}
public void lookHome(){
System.out.println("看家");
}
}
class Animal{
public static void main(String[] args){
Cat d=new Dog();
d.eat();
Dog s=(Dog)d;
s.lookHome();
}
} |
|