您好,欢迎访问三七文档
当前位置:首页 > 建筑/环境 > 工程监理 > Java东华理工大学试卷B
温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第1页共9页专业班级学号姓名东华理工大学2012—2013学年第1学期考试试卷JAVA程序设计课程闭卷课程类别:考查B题号一二三四五六七八九总分分数评卷人1选择题(共35分)1.Whatissuffix(后缀)ofJavaclassfile?()?A、.javaB、.classC、.txtD、.ext2.WhichcommandcanrunJavaclassfile?()?A、editB、dirC、javaD、javac3.Whichidentifiesisillegal()?A、$_123B、中国C、you_can_alDsome++name4.Whichconversion(转换)islegal()?A、intx=1000.1;B、intx=’a’;C、shortx=10000;D、intx=12L;5.classexample{publicstaticvoidmain(Stringargs[]){booleanb;b=(43)&&(32);System.out.print(b=+b);b=false||true;System.out.println(b=+b);}}Whatistheresult?()A、b=falseb=trueB、b=trueb=falseC、b=trueb=trueD、b=falseb=false6.classexample{publicstaticvoidmain(Stringargs[]){int[]a={1,2,3,4,5};inti=3;a[i--]=a[i--]+2;System.out.println(a[i++]);}}Whatistheresult?()A,4B,5C3,D,27.classgggg{Stringtr=newString(hello);char[]th={'a','b','n'};publicvoidchange(Stringstr,charch[]){str=tcwtok;ch[0]='z';}publicstaticvoidmain(Stringargs[]){ggggex=newgggg();温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第2页共9页专业班级学号姓名ex.change(ex.tr,ex.th);System.out.print(ex.tr+and);System.out.print(ex.th);}}Whatistheresult?()AhelloandabcBhelloandokChelloandzbnDtcwtok8.Setx=1,y=2,z=3,expressiony-=z--%++x;whatisresult()A1B3.5C4D59.Whatisresult?()classexample{staticintb=8;inta=4;publicstaticvoidmain(Stringargs[]){newexample().b++;newexample().a+=2;System.out.println(newexample().a);}}A6B7C4D510.1.classX{2.publicstaticvoidmain(Stringargs[]){3.Strings1=newString(“true”);4.Booleanb1=newBoolean(true);5.if(!s1.equals(b1)){6.System.out.println(“equal”);}}}AtheprogramrunsandprintsnothingBtheprogramrunsandprints“equal”CAnerroratline5causescompilationtofailDTheprogramrunsbutabortswithanexception11.1.interfaceA{2.voiddisplay(){};3.voidshow();4.}5.classBimplementA{6.voidshow(){}7.publicdisplay(){}publicstaticvoidmain(Stringargs[]){}}Whichlinesareincorrectwhenthecodeiscompiled?A57B256C568D5612.classA{inta=2;voidshow(){System.out.println(“s”);}}温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第3页共9页专业班级学号姓名classBextendsA{inta=3;voidshow(){System.out.println(“v”);}}classtest{publicstaticvoidmain(Stringargs[]){Ag=newB();g.show();}}Whatisresult?()AsBnoresultCvDsv13.whatisresult()classA{publicstaticvoidmain(Stringargs[]){try{thrownewArrayIndexOutOfBoundsException();inta=1/0;}catch(ArrayIndexOutOfBoundsExceptione){System.out.print(vvv);}catch(ArithmeticExceptione){System.out.print(rrr);}finally{System.out.println(sss);}}}ArrrvvvBrrrsssCvvvsssDerror14.classA{finalinti4=(int)(Math.random()*20);staticfinalinti5=(int)(Math.random()*20);publicvoidprint(){System.out.println(i4=+i4+i5=+i5);}publicstaticvoidmain(Stringargs[]){Ag1=newA();g1.print();Ag2=newA();g2.print();}}Assumei4=15i5=16wheng1.print()methodisexecuted.whatresultisdisplayedwheng2.print()isexecuted()A1516B1517C1814D151515.classA{voidf(intx){System.out.println(x);}voidf(longx){System.out.println(x);}温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第4页共9页专业班级学号姓名publicstaticvoidmain(Stringargs[]){Ag1=newA();g1.f((short)5.6);}}Whatisresult()A5.6B5C6Derror二、翻译题20分,每小题5分1)Inobject-orientedprogramming(OOP),inheritanceisawaytocompartmentalizeandreusecodebycreatingcollectionsofattributesandbehaviorscalledobjectswhichcanbebasedonpreviouslycreatedobjects.2)Inclassicalinheritancewhereobjectsaredefinedbyclasses,classescaninheritotherclasses.Thenewclasses,knownassubclasses(orderivedclasses),inheritattributesandbehaviorofthepre-existingclasses,whicharereferredtoassuperclasses,ancestorclassesorbaseclasses.3)Withouttheuseofhierarchies,eachobjectwouldneedtodefineallofitscharacteristicsexplicitly.However,byuseofinheritance,anobjectneedonlydefinethosequalitiesthatmakeituniquewithinitsclass.Itcaninherititsgeneralattributesfromitsparent.Thus,itistheinheritancemechanismthatmakesitpossibleforoneobjecttobeaspecificinstanceofamoregeneralcase.Let’stakeacloserlookatthisprocess.温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第5页共9页专业班级学号姓名4)Javaisanobject-orientedprogramminglanguage.Butwhatareobjects?Anobjectisaself-containedentitywhichhasitsownprivatecollectionofproperties(i.e.data)andmethods(i.e.operations)thatencapsulatefunctionalityintoareusableanddynamicallyloadedstructure.三程序阅读题(每题4分,共计20分):Theresultoffollowingprogramis:_________________________intk=0;Label:for(inti=1;i3;i++){for(intj=1;j3;j++){k+=i+j;System.out.println(k);if(i==2)continueLabel;}}Theresultoffollowingprogramis:________________________importjava.io.*;publicclassabc{publicstaticvoidmain(Stringargs[]){inti,s=0;温馨提示:端正考风、严肃考纪、诚信参加考试凡是代考、使用通讯设备作弊、二次作弊,一经发现开除学籍。专用考试纸请勿浪费卷第6页共9页专业班级学号姓名inta[]={20,30,40,50,60,70,80,90,100,110,120};for(i=0;ia.length;i++)if(i%3==0)s+=a[i];System.out.println(s=+s);}}Theresultoffollowingprogramis:________________________importjava.util.*;classTree{intheight;Tree(){prt(Plantingaseedling);height=0;}Tree(inti){prt(CreatingnewTreethatis+i+feettall);height=i;}voidinfo(){prt(Treeis+height+feettall);}voidinfo(Strings){prt(s+:Treeis+height+feettall);}staticvoidprt(Strings){System.out.println(s);}}pub
本文标题:Java东华理工大学试卷B
链接地址:https://www.777doc.com/doc-6222301 .html