类 Teacher 和 Student 是类 Person 的子类; Teacher t; Student s; // t and s are all non-null. if (t instanceof Person ){ s=(Student)t; } 最后一条语句的结果是:A.将构造一个Student 对象;B.表达式是合法的;C.表达式是错误的;D.编译时正确, 但运行时错误。

类 Teacher 和 Student 是类 Person 的子类; Teacher t; Student s; // t and s are all non-null. if (t instanceof Person ){ s=(Student)t; } 最后一条语句的结果是:

A.将构造一个Student 对象;

B.表达式是合法的;

C.表达式是错误的;

D.编译时正确, 但运行时错误。


参考答案和解析
编译时正确,但运行时错误

相关考题:

阅读以下说明和java代码,将应填入(n)处的字句写在对应栏内。[说明]有若干教师,每个教师只有姓名,一个教师可以指导多名研究生;每名研究生有姓名和研究方向,程序最后输出每个教师指导的所有研究生的姓名和研究方向。[Java程序]public class Teacher {String name;int top=0;Student[] student=new Student[20];public Teacher() {}public Teacher(String name) { this.name=name;}boolean add(Student stu){int len=this.student.length;if (top<len-1) {this.student[top]=siu;(1);return true;}elsereturn (2);}void disp(){System.out.println(“指导老师"”+this.name);System.out.println(“研究生:”);for(int i=0;i<(3);i++){System.out.println(“姓名:”+this.student[i].name+“\t研究方向:”+this.student[i]. search);}}public static void main(String[] args){Teacher t[]={new Teacher(“李明”),new Teacher(“王华”)};Student s1 = new Student(“孙强”,“数据库”);Student s2 = new Student(“陈文”,“软件工程”);Student s3 = new Student(“章锐”,“计算机网络”);if(! t[0].add(s1)) {System.out.println(“每个老师最多只能指导20个学生!”);}if(! t[0].add(a2)) {System.out.println(“每个老师最多只能指导20个学生!”);}if(! t[1].add(s3)) {System.out.println(“每个老师最多只能指导20个学生!”);}for(int i=0;i<2;i++)(4);}}class (5) {String name;String search;public Student(){}public Student(String name,String search){this.name=name;this.search=search;}String getName(){return this.name;}String getSearch(){return this.search;}}

( 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的派生类

_______ is characteristics of good assessment for classroom purposes. A.The content of the assessment should match the teacher’s educational objectivesB.The items should represent partial range of knowledgeC.Expectations for student performance needn’t to be clearD.The assessment should involve extraneous factors

It was an unpleasant task for the teacher to point out or hint at a student’s confusion in thought.(The Teacher as Dragon) () 此题为判断题(对,错)。

使用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,"计算机学院","教授");}

The student’s parents felt ____ as they learned that he didn’t make progress in his courses.A. incentiveB. dignityC. anxietyD. intention

Teacher:Where is Mike this morning?Student:He's got a cold.Teacher:______A、He is absent.B、What's the matter with him?C、Just tell him to take it easy.D、What? Where is he?

设串s="student.",t=“good",则执行StrInsert(s,1,t)后,s为()。 A."good student."B."good student"C."goodstudent"D."good teacher"

创建一个名为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

创建一个名为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的派生类

( 33 ) 创建一个名为 student 的新类 , 保存新类的类库名称是 mylib, 新类的 父 类是 P erson, 正确的命令是A ) CREATE CLASS mylib OF student A s P ersonB ) CREATE CLASS student OF P erson A s mylibC ) CREATE CLASS student OF mylib A s P ersonD ) CREATE CLASS P erson OF mylib A s student

What is the teacher doing in terms of error correction?S: I go to the theatre last night.T: You go to the theatre last night?A.Correcting the student's mistake.B.Hinting that there is a mistake.C.Encouraging peer correction.D.Asking the student whether he really went to the theatre.

Which of the following words in bold is pronounced with a falling tone?A.Have you finished your homework?B.Are you a student or a teacher?C.What's your first name?D.Isn't it beautiful?

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.

T: You GO to the theatre last night?A.the student’s mistake.B.Hinting that there is a mistake.C.Encouraging peer correction.D.Asking the Student whether he really went to the theatre.

T: You GO to the theatre last night?A.Correcting the student’s mistake.?B.Hinting that there is a mistake.C.Encouraging peer correction.D.Asking the Student whether he really went to the theatre.

When a student said in class," I come home at 6 o'clock yesterday", the teacher says "Came not comed". The teacher's response does not obey which rule of effective feedback?A.relevanceB.accuracyC.guidanceD.timeliness

类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、 编译时正确,但运行时错误。

单选题The teacher-student _____ in China’s universities is much lower than that in the U.S.ArateBrankCratioDrange

多选题定义字符数组正确的是()。Achars[]=Student;Bchars[7]=Student;Cchars[7]={’S’,’t’,’u’,’d’,’e’,’n’,’t’};Dchars[]={Student};

单选题What is the teacher doing in terms of error correction?“ S: I go to the theatre last night.”T: You GO to the theatre last night?A.Correcting the student’s mistake.B.Hinting that there is a mistake.C.Encouraging peer correction.D.Asking the student whether he really went to the theatre.AABBCCDD

多选题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

单选题Now little has been done to ______.Adecide a student’s jobBtest a student’s abilityCtest a student’s knowledgeDtest a student’s memory

单选题All of Mark's former students go to college. If the statement above is true, which of the following must also be true?AIf Ethan was not Mark's student, then he is not going to college.BIf Joyelle goes to college, then she was not Mark's student.CIf Ginger goes to college, then she was Mark's student.DIf Stephanie was Mark's student, then she is not going to college.EIf Steve does not go to college, then he was not Mark's student.

单选题类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 编译时正确,但运行时错误。