网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
设有下面两个类的定义。 class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 } intgetScore() { return score;} } 则类Person和类Student的关系是? }
A.包含关系
B.继承关系
C.关联关系
D.上述类定义有语法错误
参考答案
更多 “ 设有下面两个类的定义。 class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 } intgetScore() { return score;} } 则类Person和类Student的关系是? } A.包含关系B.继承关系C.关联关系D.上述类定义有语法错误 ” 相关考题
考题
能将程序补充完整的选项是( )。class Person{ private int a; public int change(int m){ return m; }}public class Teacher extends Person{ public int b; public static void main(String arg[]) { Person p = new Person(); Teacher t = new Teacher(); int i; ______ }} B.A.i=mB.i=bC. i=p.aD.i=p. change(50)
考题
( 30 )下列代码声明了 3 个类class Person{};class Student:public Person{};class Undergraduate:Student{};下列关于这些类之间关系的描述中,错误的是A )类 Person 是类 Undergraduate 的基类B )类 Undergraduate 从类 Student 公有继承C )类 Student 是类 Person 的派生类D )类 Undergraduate 是类 Person 的派生类
考题
设有下列两个类的定义,则类Person和类Man的关系是( )。 class Person { long id; //身份证号 String name; //姓名 } class Man extends Person { int age; //年龄 int getAge() { return age; } }A.包含关系B.继承关系C.关联关系D.无关系,上述类定义有语法错误
考题
下列代码段声明了3个类:class Person();class Student:public Person{};class Undergraduate:Student{};下列关于这些类之间关系的描述中,错误的是( )。A.类Person是类Undergraduate的基类B.类Undergraduate从类Student公有继承C.类Student是类Person的派生类D.类Undergraduate是类Person的派生类
考题
给出下列的不完整的类代码,则哪个语句可以被加到横线处? ( ) class Person{ String name,department; int age; public Person(String n){name=n;} public Person(String n,int s){name=n; age=a;} public Person(String n,String d,int a){ department=d;______ } }A.Person(n,a);B.this(Person(n,a));C.this(n,s);D.this(name,age);
考题
使用VC6打开考生文件夹下的工程test4_3。此工程包含一个源程序文件test4_3.cpp,其对一个学校的教师和考生情况进行了描述。由于教师和考生之间有相同的信息,如姓名、年龄等,所以可抽象出一个基类person,考生类student和教师类teacher作为person类的派生类。请按要求完成下列操作,将程序中的类定义补充完整。(1)定义基类person的私有数据成员name和age,分别用于表示姓名和年龄,name为字符指针,age为血型的数据。请在注释“//**1**”之后添加适当的语句。(2)完成基类person的重载构造函数person(char *mint a)的定义,把数据成员name,age分别初始化为参数n,a的值,请在注释“//**2**”之后添加适当的语句。(3)根据主函数main中对s1的声明,定义派生类student的构造函数。在注释“//**3**”之后添加适当的语句。(4)完成派生类teacher成员函数void setinf(ehar *n,int a,char *d,char *1)的定义,其功能为记录教师的姓名、年龄、院,系与职称信息。请在注释“//**4**”之后添加适当的语句。输出结果如下:刘雷(45)destructor蒋军(23)destructor注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test4_3.cpp清单如下:include<iostream.h>class person{//**1**public:person(){}person(char *n,int a){//**2**}void setname(char *n){name=n;)void setage(int a){age=a;}~person(){cout<<name<<"("<<age<<")destructor"<<endl;)};class student:public person{char *department;int code;public://**3**{department=d;code=c;}};class teacher:public person{char *department;char *level;public:teacher(){}void setinf(char *n,int a,char *d,char *1){//**4**department=d;level=1;}};void main(){student s1("蒋军",23,"计算机学院",2);teacher t1;t1.setinf("刘雷",45,"计算机学院","教授");}
考题
设有下面两个类的定义:classperson{longid;//身份证号stringname;//姓名}classstudentextendsperson{intscore;//入学总分intgetscore(){returnscore;}}则类person和类student的关系是_________。
A.关联关系B.上述类定义有语法错误C.继承关系D.包含关系
考题
下列程序运行后的输出结果是( )。#include#includeusing namespace std;class Person{public:Person(string n):name(n) { coutprivate:int year,month,day;};class Student:public Person{public:Student(string n,int y,int m,int d,char c):birthday(y,m,d),sex(c),Person(n) { coutA. SB.PSC.DPSD.PDS
考题
创建一个名为student的新类,保存新类的类库名称是mylib,新类的父类是Person,正确的命令是A.CREATE CLASS mylib OF student As PemonB.CREATE CLASS student OF Pe~on As mylibC.CREATE CLASS student 0F mylib As Pe~onD.CREATE CLASS Person OF mylib As student
考题
阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是A.staticB.abstractC.protectedD.final
考题
给出下列的不完整的类代码,则下列的( )语句可以加到横线处。 class Person{ String name,department; int age public Person(String n){name=n;} public Person(String n,int a){name=n;age=a;} pubilc Person(String n,String d,int a) { _______________ department=d; } }A.Person(n,a);B.this(Person(n,a));C.this(n,a);D.this(name,age);
考题
给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,intA.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);B.this (Person(n,A));C.this(n,A);D.this(name,age);
考题
设有下列两个类的定义,则类Person和类Man的关系是 ( ) class Person{ long id;//身份证号 Stringname;//姓名 } class Man extends Person{ int age;//年龄 int getScore(){ return score; } }A.包含关系B.继承关系C.关联关系D.无关系,上述类定义有语法错误
考题
设有下面两个类的定义: class Person{ long id // 身份证号 String name; //姓名 } class Student extends Person{ int score: //成绩 int getScore ( ) { return score; } } 则类Person和类Student的关系是( )。A.包含关系B.继承关系C.关联关系D.无关系
考题
阅读以下说明和Java 码,将应填入(n)处的字名写在的对应栏内。[说明] 编写一个学生类Student,要求:(1) 学生类Student 属性有:id: long 型,代表学号name: String类对象,代表姓名age: int 型,代表年龄sex: boolen 型,代表性别(其中:true 表示男,false 表示女)phone: String 类对象,代表联系电话(2) 学生类Student 的方法有:Student (long i,String n,int a,boolean s,String p):有参构造函数,形参表中的参数分别初始化学号、姓名、年龄、性别和联系电话。int getAge ():获取年龄作为方法的返回值。boolean getSex ():获取性别作为方法的返回值。String getPhone ():获取联系电话作为方法的返回值。public String to String ():以姓名:性别:学号:联系电话的形式作为方法的返import java. applet. Applet;import java. awt.* ;public class Student extends Applet {long id;String name, phone;int age;boolean sex;Student(long i, String n, int a, boolean s, String p){id=i;name = n;age = a;sex= s;phone = p;{public void paint( Graphics g){Student x= new Student (5000," xiaoliu" , 89, true, " 8989898" );(1);(2)g. drawstring( x. getPhone( ), 140,140);}int getAge( ){ return age; }boolean getsex ( ){ return sex; }String getPhone( ){ return phone; }String ToString( ){(3)}}
考题
创建一个名为student的新类,保存新类的类库名称是mylib,新类的父类名是Person,正确的命令是( )。A.CREATE CLASS mylib OF student AS PcrsonB.CREATE CLASS student OF Person AS mylibC.CREATE CLASS student OF mylib AS PersonD.CREATE CLASS Person OF mylib AS student
考题
下列数据类型定义中,正确的是A.Type Student Num As Long Name As String End TypeB.Type Student Num As Integer Name As String * 10 End TypeC.Private Type Num As Long Score As Single End TypeD.Private Type Student Name As String Score(10)As String * 10 End Type
考题
要求:1. 按如下类图写出相应数据库建表 sql 脚本。 其中 Student 和 Score 是1 对多的关系,Scroe 和 Course是多对 1 的关系。Student-id: String-name: String-birthday: Date-address: String-phone: String-email: StringScore-student: Student-course: Course-grade: floatCourse-id: String-name: String-description: String
考题
设有下列两个类的定义,则类Person和类Man的关系是 ( ) class Person { long id; //身份证号 String name; //姓名 } class Man extends Person{ int age;//年龄 int getScore() { return score; } }A.包含关系B.继承关系C.关联关系D.无关系,上述类定义有语法错误
考题
public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if(! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person?() A、 return super.hashCode();B、 return name.hashCode() + age * 7;C、 return name.hashCode() + comment.hashCode() /2;D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;
考题
类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?() A、 0B、 nullC、 falseD、 编译错误
考题
在C#中,假设Person是一个类,而ITeller是一个接口,下面的()类声明是正确的。A、class Employee:Person,ITeller B、class Employee:ITeller,PersonC、class Employee-Person,ITellerD、class Employee:Person / ITeller
考题
单选题类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()A
0B
nullC
falseD
编译错误
考题
多选题Which are syntactically valid statement at// point x?() class Person { private int a; public int change(int m){ return m; } } public class Teacher extends Person { public int b; public static void main(String arg[]){ Person p = new Person(); Teacher t = new Teacher(); int i; // point x } }Ai = m;Bi = b;Ci = p.a;Di = p.change(30);Ei = t.b.
考题
单选题创建一个名为student的新类,保存新类的类库名称是mylib,新类的父类是Person,正确的命令是( )。A
CREATE CLASS mylib OF student As PersonB
CREATE CLASS student OF Person As mylibC
CREATE CLASS student OF mylib As PersonD
CREATE CLASS Person OF mylib As student
考题
单选题public class Person { private String name, comment; private int age; public Person(String n, int a, String c) { name = n; age = a; comment = c; } public boolean equals(Object o) { if(! (o instanceof Person)) return false; Person p = (Person)o; return age == p.age name.equals(p.name); } } What is the appropriate definition of the hashCode method in class Person?()A
return super.hashCode();B
return name.hashCode() + age * 7;C
return name.hashCode() + comment.hashCode() /2;D
return name.hashCode() + comment.hashCode() / 2 - age * 3;
考题
单选题Given the uncompleted code of a class: 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, String d, int a) { // doing the same as two arguments version of constructor // including assignment name=n,age=a department = d; } } Which expression can be added at the "doing the same as..." part of the constructor?()A
Person(n,a);B
this(Person(n,a));C
this(n,a);D
this(name,age);
热门标签
最新试卷