设有下面两个类的定义: class Person {} class Student extends Person { long id; // 身份证号 int score; // 入学总分 String name; // 姓名 int getScore(){return score;} } 问:类Person和类Student的关系是
举一反三
- class Person{} class Student extends Person{ public int id; public int score; public String name; public int getScore() { return score; }
- 已知下列接口和抽象类:interface Tool{int add(int x,int y);//返回参数和int max(int x,int y);//返回参数最大值}abstract Person{abstract String setName(String name);//设置姓名}要求:定义一个类class Student{…},继承Person类,实现Tool接口。
- 在C#中,下列结构或者类定义正确的是(选一项) A: public struct Person{ string name; int age; public void ShowName(){ Console.WriteLine(name); }} B: public struct Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} C: public class Person{ string name; int age; public Person(){ Conssole.WriteLine(name); }} D: public class Person{ string name; int age; public Person(string name){ Conssole.WriteLine(name); }}
- (6-2)定义如下Person类,(1)处合理的代码是。 class Person { String name, department; int age; public Person(String n) { name = n; } public Person(String n, int a) { name = n; age = a; } public Person(String n, int a, String d) { ① department = d; } }
- python中,下列哪种语法表示Student从Person中继承。( ) A: class Student: Person B: class Student extends Person C: class Student (Person) D: class Student: class Person