给出下列的不完整的类代码,则哪个语句可以被加到横线处? ( ) 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);
给出下列的不完整的类代码,则哪个语句可以被加到横线处? ( ) 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);
相关考题:
在J2EE中,使用()选项中的代码,可以生成如下XML文档:PEOPLEPERSONNAMETonyBlair/NAME/PERSONPEOPLE A.Elementpeople=doc.createElement(PEOPLE);Elementperson=doc.createElement(PERSON);Elementname=doc.createElement(NAME);name.appendChild(doc.createTextNode(TonyBlair));people.appendChild(person);person.appendChild(name);doc.appendChild(people);B.Elementpeople=doc.createElement(PEOPLE);Elementperson=doc.createElement(PERSON);people.appendChild(person);Elementname=doc.createElement(NAME);name.appendChild(doc.createTextNode(TonyBlair));person.appendChild(name);doc.appendChild(people);C.Elementpeople=doc.createElement(PEOPLE);Elementperson=doc.createElement(PERSON);people.appendChild(person);Elementname=doc.createElement(NAME);name.appendText(doc.createTextNode(TonyBlair));person.appendChild(name);doc.appendChild(people);D.Elementpeople=doc.createElement(PEOPLE);Elementperson=doc.createElement(PERSON);Elementname=doc.createElement(NAME);name.createTextNode(TonyBlair);people.appendChild(person);person.appendChild(name);doc.appendChild(people);
class Person{ String name,department; int age; public Person(Stringn){name=n;} public Person(String n, int a){name=n;age=a;} publicPerson(String n,String d,int a){ doing the same as two argumentsversion of constructer including assignment name=n,age=a } } 下列哪一个选项可以添加到“doing the same....”处?()APerson(n,a)Bthis(Person(n,a))Cthis(n,a)Dthis(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,"计算机学院","教授");}
有以下程序:includeincludeusingnameSpacestd;classperson{ intage; Char*nam 有以下程序:include <iostream>include <string>using nameSpace std;class person{int age;Char * name;public:person ( int i, Char * str ){int j;j = strlen( str ) + 1;name = new char[ j ];strcpy( name, str );age = i;}~person(){delete name;cout<<"D";}void display(){cout<<name<<":"<<age;}};int main(){person demo( 30,"Smith" );demo.display();return 0;}则该程序的输出结果为:【 】。
给出下列的不完整的类代码,则下列的( )语句可以加到横线处。 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);
给出下列的不完整的类代码,则下列的哪个语句可以加到横线处? 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 ) { _____________ department = d; } }A.Person(n,a);B.this(Person(n,a) );C.this(n,a);D.this(name,age);
10、通过下面的代码片段来回答问题。 _________ User { var uuid:UUID var name:String init(uuid: UUID, name:String) { self.uuid = uuid self.name = name } } 下划线处可以填写哪些关键词?A.protocolB.structC.enumD.class
若有如下定义,则下面能输出字母M的语句是()。struct person{ char name[9]; int age; }; struct person class[10]={"John",17,"paul",19,"Mary",18,"Adam",16};A.printf("%cn",class[3].name);B.printf("%cn",class[3].name[1]);C.printf("%cn",class[2].name[1]);D.printf("%cn",class[2].name[0]);