python中,下列哪种语法表示Student从Person中继承。( )
A: class Student: Person
B: class Student extends Person
C: class Student (Person)
D: class Student: class Person
A: class Student: Person
B: class Student extends Person
C: class Student (Person)
D: class Student: class Person
举一反三
- 下面声明正确的是( )。 A: abstract final class Student{} B: public abstract class Student{} C: class Student extends Person,Parent{} D: private class Person{}
- class Person{} class Student extends Person{ public int id; public int score; public String name; public int getScore() { return score; }
- 设有下面两个类的定义: class Person {} class Student extends Person { long id; // 身份证号 int score; // 入学总分 String name; // 姓名 int getScore(){return score;} } 问:类Person和类Student的关系是
- 【单选题】下列代码段声明了3个类: classPerson{); class Student :public Person{}; class Undergraduate :Student{}; 下列关于这些类之间关系的描述中,错误的是()。 A. 类Person是类Undergraduate的基类 B. 类Undergraduate从类Student公有继承 C. 类Student是类Person的派生类 D. 类Undergraduate是类Person的派生类
- class Person: def __init__(self,n="xxx"): self.name=n class Student(Person): def __init__(self,s="male"): self.sex=s def show(self): print(self.name,self.sex) s=Student("female") s.show() 结果: