public class Test {
Father f1=new Son();
Father f2=new Son();
f1.getAge();
f2.getAge(60);
}
class Father{
String sex="man";
int age=50;
public String getSex() {
return sex;
}
public int getAge() {
System.out.println("父类的方法:");
return age;
}
}
class Son extends Father{
public int getAge() {
System.out.println("子类的方法:");
return age;
}
public int getAge(int age) {
this.age=age;
return age;
}
}
|