publicclassItemTest{privatefinalmtid;publicItemTest(intid){this.id=id;}publicvoidupdateId(intnewId){id=newId;}publicstaticvoidmain(String[]args){ItemTestfa=newItemTest(42);fa.updateId(69);System.out.println(fa.id);}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.TheattributeidintheItemobjectremainsunchanged.D.TheattributeidintheItemobjectismodifiedtothenewvalue.E.AnewItemobjectiscreatedwiththepreferredvalueintheidattribute.
publicclassItemTest{privatefinalmtid;publicItemTest(intid){this.id=id;}publicvoidupdateId(intnewId){id=newId;}publicstaticvoidmain(String[]args){ItemTestfa=newItemTest(42);fa.updateId(69);System.out.println(fa.id);}}Whatistheresult?()
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.TheattributeidintheItemobjectremainsunchanged.
D.TheattributeidintheItemobjectismodifiedtothenewvalue.
E.AnewItemobjectiscreatedwiththepreferredvalueintheidattribute.
相关考题:
设有定义:struct person{ int ID;char name[12];}p;请将 scanf("%d", 【 1 2 】 ); 语句补充完整,使其能够为结构体变量 p 的成员 ID 正确读入数据。
有以下类定义 class MyClass { private: int id; Char gender; Char*phone; public: MyClass():id(0),gender(‘#’),phone(NULL){} MyClass(int no,charge=’#’,char*ph=NULL) {id=no;gender=ge;phone=ph;} ); 下列类对象定义语句中错误的是( )。A.MyClass myObj;B.MyClass myObj(11,”13301111155”);C.MyClassmyObj(12,’m’);D.MyClassmyObj(12);
阅读下列程序说明和C程序,将应填入程序中(n)处的字句,写在对应栏内。【程序说明】本程序先从文件读人各考生的准考证号(设为整型数)及成绩,并将其存放在一棵检索二叉树上,二叉树结点的健值是成绩,每个结点带一链表,链表结点存放取得该成绩的考生的准考证号。然后,程序按中序遍历检索二叉树,从高分到低分输出结果,使每行输出成绩及其取得成绩的考生的准考证号。【程序】include < stdio. h >typedef struet idnode {int id;struct idnode * next;} ldNode;typedef struct marknode Iint mark;ldNode * head;struct marknode * left, * right;} MarkNode;char fname [ ] = "sp07.dat";main( ){ int id, mark;MarkNode * root = null;FILE * fp = fopen(fname," r" );if(!fp) {printf("file%s open error, \n" , fname);exit(0);}while (!feop(fp)) {fscanf(fp," %d%d", id, mark);btree(root, id, mark);}fclose(fp);print(root);}btree(MarkNod * * mpptr, int id, int mark){ ldNode * ip;MarkNode *mp = * mpptr;if (1) {if (mark==p->mark) addldNODE ((2), id);else if ( mark >mp -> mark) btree (top -> left, id, mark);else btree(mp-> right, id, mark);} elseImp = ( marknode * ) malloc(sizeo (marknode) );mp -> mark = mark;mp -> left =mp -> right = NULL;(3)addldNode(mp -> head, id);(4);}}addldNode(ldNode * * ipp, int id){ ldNode * ip = * ipp;if ((5))addldNode ((6)), id;else {ip = (ldNode * )malloc(sizeof(ldNode) );sp - > id = id;ip -> next = NULL;(7)}}print(MarkNode * rap){ ldNode *ip, *ip0;if (mp) {print ( mp -> left);printf(" %6d: \t" ,mp -> mark);ip = mp -> head;while(ip) {printf(" %6d" ,ip -> id);ip0 =ip;ip = ip -> next;free (ip0);}printf(" \n" ); printf( mp -> right); free(mp);}}
请使用VC6或使用【答题】菜单打开考生文件夹projl下的工程projl。程序中位于每个“//ERROR****found料****之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name:Smith Age:21 ID:99999 CourseNum:12 Record:970 注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。 includeiostream using namespace std; class Studentlnfo { protected: //ERROR********************found**************** char Name; int Age; int ID: int CourseNum; float Record; public: Studentlnfo(char*name,int Age,int ID,int coumeNum,float record); //ERROR ********************found******************** void~Studentlnfo{} float AverageRecord{ return Record/CourseNum; } void showconst{ cout”Name:”Name”Age:”Age”ID:”ID ”CourseNum:”CourseNum”Record:”Recordendl; } }; //ERROR ******************found************** StudentInfo StudentInfo(char*Name,int Age,int ID,int CourseNum,float Record) { Name=name; Age=age; this一ID=ID: CourseNum=courseNum: Record=record; } int main { Studentlnfo st(’’Smith”,21,99999,12,970); st.show; return 0; }
有以下类定义。 class MyClass { private: int id; char gender; char *phone; public: MyClass():id(0),gender('#'),phone(NULL){} MyClass(int no,char ge='#',char *ph=NULL) {id=no;gender=ge;phone=ph;) }; 下列类对象定义语句中错误的是( )。A.MyClass myobj;B.MyClass myobj(11,"13301111155");C.MyClass myobj(12,'m');D.MyClass myobj(12);
TestClass类定义如下: class TestClass { private: intid; char gender; char*phone; public: TestClass ():id(0),gender('#'),phone(NULL){) TestClass(int no,char ge='#',char *ph=NULL) {id=no;gender=ge;phone=ph;} }; 下面类对象定义语句中错误的是( )。A.TestClass myObj(i);B.TestClass myObj(2,"11101111155");C.TestClass myObj(1,'m');D.TestClass myObj;
关于结构体成员变量Id内容或地址,下面的使用非法的是() struct Student { int Id; }stu,*p;A.Student.IdB.(p->Id)C.p->IdD.stu.Id
判断下面程序编译是否正确,如果错误简要说明原因 class Person { public: void setID(const int id ) const { this->id = id; } private: int id ; };