单选题:设有下面两个类的定义,类 Person 和类 Student 的关系是( )。
设有下面两个类的定义,类 Person 和类 Student 的关系是( )。
class Person {
long id; // 身份证号
String name; // 姓名
}
class Student extends Person {
int score; // 入学总分
int getScore(){
return score;
}
}
A.包含关系
B.实现关系
C.继承关系
D.没有关系
答案:C
class Person {
long id; // 身份证号
String name; // 姓名
}
class Student extends Person {
int score; // 入学总分
int getScore(){
return score;
}
}
A.包含关系
B.实现关系
C.继承关系
D.没有关系
答案:C