package one;
class C{
private int age;
private String name;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void tell() {
System.out.println("姓名:"+getName()+"年龄 "+getAge());
}
public void setScore(int i) {
}
public void say() {
}
}
class D extends C{
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public void say() {
System.out.println("成绩:"+getScore());
}
}
public class Person {
public static void main(String[] args) {
// D d=new D();
// d.setAge(20);
// d.setName("张三");
// d.setScore(100);
// d.tell();
// d.say();
C c=new C();
c.setAge(20);
c.setName("张三");
c.setScore(100);
c.tell();
c.say();//为什么我写了这个语句但是哈,他却显示不出来它的成绩?这是为什么?我不是已经在子类里面重写了父类的方法了吗
}
}