public class Cat extends Animal {
public int age=20;
public void eat(){
System.out.println("猫吃鱼");
}
}
public class Animal {
public int age=10;
public void eat(){
System.out.println("动物吃东西");
}
}
public class input {
public static void main(String[] args) {
Animal a= new Cat();
System.out.println(a.age);//10
a.eat();//猫吃鱼
}
}
12-08
640
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)