网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

类Teacher和Student都是类Person的子类 Person p; Teacher t; Student s; 若p,t和s都是非空值 if(t instanceof Person) { s = (Student)t; } 若默认new时声明的都是本类,这个语句导致的结果是()

A.将构造一个Student对象

B.表达式合法

C.编译时非法

D.编译时合法而在运行时可能非法


参考答案和解析
C
更多 “类Teacher和Student都是类Person的子类 Person p; Teacher t; Student s; 若p,t和s都是非空值 if(t instanceof Person) { s = (Student)t; } 若默认new时声明的都是本类,这个语句导致的结果是()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;}}

考题 能将程序补充完整的选项是( )。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的派生类

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

考题 使用VC6打开考生文件夹下的工程test28_3。此工程包含一个test28_3.cpp,其中定义了类Person,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)定义类Person的私有数据成员forename、surname 和 money,forename 和 surname都是char型的指针数据,money是double型的数据。请在注释“//**1**”之后添加适当的语句。(2)完成类Person的带三个参数的构造函数Person(char *f, char *s,double m),分别为forename和surname申请新的空间来存储参数f和s指针指向的内容,注意空间的大小,最后把参数m的值赋给money,请在注释“//**2**”之后添加适当的语句。(3)完成类Person的析构函数的定义,把forename和surname指向的空间释放,请在注释“//**3**”之后添加适当的语句。(4)完成类Person的成员函数display的定义,使其以格式“forname surname has money”的形式输出内容,请在注释“//**4*。”之后添加适当的语句。注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。输出结果如下:Richard Berk has 1000.56源程序文件test28_3.cpp清单如下:include <iostream.h>include <string.h>class Person{private://** 1 **double money;public:Person(char *f, char *s, double m);~Person();void display();};Person::Person(char *f, char *s, double m){//** 2 **strcpy(forename, f);surname = new char[strlen(s)+1];strcpy(surname, s);money=m;}Person: :-Person (){//** 3 **}void Person:: display ( ){//** 4 **}void main ( ){Person p("Richard", "Berk", 1000.56);p.display ( );}

考题 设串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

考题 在下列程序的划线处应填入的语句是class Person { private int a;}public class Man extends Person{ public int b; public static void main (String arg []){ Person p=new Person(); Man t=new Man(); int i: }}A.i=w;B.i=bC.i=p.a;D.i=t.b;

考题 在下列程序的划线处应填入的语句是 class Pemon { pnvate int a; } public class Man extends Person { public int b; public static void main(String arg[ ] ) { Person p = new Person( ); Man t = new Man( ); int i; ________ } }A.i = w;B.i = b;C.i = p.a;D.i = t.b;

考题 设有下面两个类的定义: 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.上述类定义有语法错误

考题 在下列程序的划线处应填入的语句是( )。 class Person { private int a: } public class Man extends Person{ public int b; public static void main(String arg []){ Person p=newPerson(); Man t=new Man(); int i; _________________ } }A.i=w;B.i=b;C.i=P.a;D.i=t.b;

考题 阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】本程序用于评选优秀教师和学生。当输入一系列教师或学生的记录后,将优秀学生及教师的姓名列出来。其类结构如下图所示:【程序】include <iostream.h>include <stdio. h>class base{protected:char name[8];public:void getname(){cout<<"name:"; cin>>name;}void printname(){cout<<"name:"<<name<<endl;}(1)};class student: (2){int num;public:void getnum(){cout<<"score:"; cin>>num;}bool isgood(){return (3) }};class teacher: (2){int num;public:void getnum(){cout<<"paper:"; cin>>num;}bool isgood(){return (num>3)?true:false;}void main(){base *p[50];student *pstud;teacher *ptech;char ch;int count=0;do{cout<<"input teacher(t) or student(s):";cin>>ch;if(ch=='s'){pstud=new student;pstud->getname();pstud->getnum();p[count++]=pstud;}else if(ch=='t'){(4)ptech->getname();ptech->getnum();p[count++]=ptech;}elsecout<<"input is wrong"<<endl;cout<<"continue to iput(y/n)?";cin>>ch;}while(ch=='y');for(int i=0;i<count;i++)if((5))p[i]->printname();}

考题 ( 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?

考题 对于下列代码: 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

考题 类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.A rateB rankC ratioD range

考题 多选题定义字符数组正确的是()。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.A AB BC CD D

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

考题 单选题对于下列代码: 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

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