单选题类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; //p, t and s are all non-null. if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是:()A 将构造一个Student对象;B 表达式是合法的;C 表达式是错误的;D 编译时正确,但运行时错误。
单选题
类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; //p, t and s are all non-null. if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是:()
A
将构造一个Student对象;
B
表达式是合法的;
C
表达式是错误的;
D
编译时正确,但运行时错误。
参考解析
解析:
暂无解析
相关考题:
在Java语言中,类Worker是类Person的子类,Worker的构造方法中有一句"super()",该语句()。 A.调用类Worker中定义的super()方法B.调用类Person中定义的super()方法C.调用类Person的构造函数D.语法错误
在Java语言中,类Worker是类Person的子类,Worker的构造方法有一句“super()”,该语句()。 A.调用Worker类中定义的super()方法B.调用类Person类中定义的super()方法C.调用类Person的构造函数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 的派生类
下列代码段声明了3个类:class Person();class Student:public Person{};class Undergraduate:Student{};下列关于这些类之间关系的描述中,错误的是( )。A.类Person是类Undergraduate的基类B.类Undergraduate从类Student公有继承C.类Student是类Person的派生类D.类Undergraduate是类Person的派生类
在Windows下,下列文件名中正确的一个是()。 A、teacher and studentB、teacher:studentC、teacher/studentD、teacher?student
使用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,"计算机学院","教授");}
创建一个名为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
创建一个名为myteacher的新类,保存新类的类库名称是mylib,新类的父类是Teacher,正确的命令是 ( )。A. CREATE CLASS mylib OF myteacher AS TeacherB. CREATE CLASS myteacher OF Teacher AS mylibC. CREATE CLASS myteacher OF mylib AS TeacherD. CREATE CLASS Teacher OF mylib AS myteacher
设有下面两个类的定义: class Person{ long id // 身份证号 String name; //姓名 } class Student extends Person{ int score: //成绩 int getScore ( ) { return score; } } 则类Person和类Student的关系是( )。A.包含关系B.继承关系C.关联关系D.无关系
创建一个名为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
下列代码段声明了3个类:classPerson{);classStudent:publicPerson{};classUndergraduate:Student{);下列关于这些类之间关系的描述中,错误的是( )。A.类Person是类Undergraduate的基类B.类Undergraduate从类Student公有继承C.类Student是类Person的派生类D.类Undergraduate是类Person的派生类
设有下面两个类的定义。 class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 } intgetScore() { return score;} } 则类Person和类Student的关系是? } A.包含关系B.继承关系C.关联关系D.上述类定义有语法错误
When a student said “All the classes will be finished before December 7th, and then students have exams”, the teacher didn't stop him to correct the tense mistake, but let him keep talking. What can we conclude from this activity?A.The teacher combined listening and speaking skills.B.The teacher focuses on fluency.C.The teacher is doing contextualized practice.D.The teacher is using different speaking activities.
类Teacher: class Teacher{ String name; float salary; Teacher(String name){ this.name = name; } Teacher(String name,float salary){ this.name = name; this.salary = salary; } } 执行语句Teacher t = new Teacher(“Tom”,2000.0f);后,字段salary的值是哪一项?() A、 2000.0fB、 0.0fC、 null;D、 2000
1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call?() A、 on line 2B、 on line 3C、 on line 6D、 on line 7
在JAVA中,类Worker是类Person的子类,Worker的构造方法中有一句“super()“,该语句()。A、调用类Worker中定义的super()方法B、调用类Person中定义的super()方法C、调用类Person的构造函数D、语法错误
在Java语言中,假设类Worker是类Person的子类,Worker的构造方法中有一句"super();",该语句()A、调用类Worker中定义的super()方法B、调用类Person中定义的super()方法C、调用类Person的构造方法D、语法错误
类Teacher和Student是类Person的子类; Person p; Teacher t; Student s; //p, t and s are all non-null. if(t instanceof Person) { s = (Student)t; } 最后一句语句的结果是:()A、 将构造一个Student对象;B、 表达式是合法的;C、 表达式是错误的;D、 编译时正确,但运行时错误。
在Java语言中,类Worker是类Person的子类,Worker的构造方法有一句“super()”,该语句()。 A、 调用Worker类中定义的super()方法B、 调用类Person类中定义的super()方法C、 调用类Person的构造函数D、 语法错误
单选题类Teacher: class Teacher{ String name; float salary; Teacher(String name){ this.name = name; } Teacher(String name,float salary){ this.name = name; this.salary = salary; } } 执行语句Teacher t = new Teacher(“Tom”,2000.0f);后,字段salary的值是哪一项?()A 2000.0fB 0.0fC null;D 2000
多选题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,正确的命令是( )。ACREATE CLASS mylib OF student As PersonBCREATE CLASS student OF Person As mylibCCREATE CLASS student OF mylib As PersonDCREATE CLASS Person OF mylib As student
单选题在Java语言中,类Worker是类Person的子类,Worker的构造方法中有一句“super()”,该语句()A 调用类Worker中定义的super()方法B 调用类Person中定义的super()方法C 调用类Person的构造函数D 语法错误
单选题1) class Person { 2) public void printValue(int i, int j) {/*…*/ } 3) public void printValue(int i){/*...*/ } 4) } 5) public class Teacher extends Person { 6) public void printValue() {/*...*/ } 7) public void printValue(int i) {/*...*/} 8) public static void main(String args[]){ 9) Person t = new Teacher(); 10) t.printValue(10); 11) } 12) } Which method will the statement on line 10 call? ()A on line 2B on line 3C on line 6D on line 7
单选题对于下列代码: 1) class Person { 2} public void printValue(int i, int j) {//... } 3} public void printValue(int i){//... } 4} } 5) public class Teacher extends Person { 6} public void printValue( ) {//... } 7} public void printValue(int i) {//...} 8} public static void main(String args[]){ 9} Person t = new Teacher( ); 10} t.printValue(10); 11} } 第10行语句将调用哪行语句?()A line 2B line 3C line 6D line 7