- abstract class Person
- {
- private String name;
- Person(String aName)
- {
- name=aName;
- }
- public String getName()
- {
- return name;
- }
- }
- class Student extends Person
- {
- private String major;
- Student(String aName,String aMajor)
- {
- super(aName);
- major=aMajor;
- }
-
- public String getInfo()
- {
- return name+"..."+major;//Student继承了Person,不是也有name
- //这个成员变量吗?为什么还出错?
- }
- }
复制代码 |
|