public class Person{
private String name=”Person”;
int age=0;
}
public class Child extends Person{
public String grade;
public static void main(String[] args){
Person p = new Child();
System.out.println(p.name);
}
}
改成这样子之后 运行结果是Person
class Test {
public static void main(String[] args) {
Person p = new Child();
System.out.println(p.name);
}
}
class Person{
String name="Person";
int age=0;
}
class Child extends Person{
public String grade;
}