public class dog {
public int age;
public String name;
public void eat() {
System.out.println(age);
System.out.println(name);
System.out.println("功能");
}
public dog() {
System.out.println("dog类执行了!");
}
}
public class Test extends dog {
public void eat() {
System.out.println("狗狗是具有吃东西的功能!");
}
public Test() {
System.out.println("Test类执行了!");
}
}
public class Initil {
public static void main(String[] args) {
// TODO Auto-generated method stub
dog eat = new dog();
eat.age = 10;
eat.name = "kaka";
eat.eat();
}
}