单项选择题

A.ThiscodeisNOTthread-safe.
B.TheprogrammercanreplaceStringBufferwithStringBuilderwithnootherchanges.
C.ThiscodewillperformwellandconvertingthecodetouseStringBuilderwillnotenhancetheperformance.
D.Thiscodewillperformpoorly.Forbetterperformance,thecodeshouldberewritten:return“<“+this.name+“>”;
相关考题

单项选择题 publicclassFoo{staticint[]a;static{a[0]=2;}publicstaticvoidmain(String[]args){}}Whichexceptionorerrorwillbethrownwhenaprogrammerattemptstorunthiscode?()

单项选择题 10.publicclassClassA{11.publicvoidmethodA(){12.ClassBclassB=newClassB();13.classB.getValue();14.}15.}And:20.classClassB{21.publicClassCclassC;22.23.publicStringgetValue(){24.returnclassC.getValue();25.}26.}And:30.classClassC{31.publicStringvalue;32.33.publicStringgetValue(){34.value=ClassB”;35.returnvalue;36.}37.}Given:ClassAa=newClassA();a.methodA();Whatistheresult?()

单项选择题 publicclassTestString1{publicstaticvoidmain(String[]args){Stringstr=420”;str+=42;System.out.print(str);}}Whatistheoutput?()

单项选择题 Whatwillbewrittentothestandardoutputwhenthefollowingprogramisrun?()publicclassQ03e4{publicstaticvoidmain(Stringargs[]){Stringspace="";Stringcomposite=space+"hello"+space+space;composite.concat("world");Stringtrimmed=composite.trim();System.out.println(trimmed.length());}}A.5B.6C.7D.12E.13

未知题型 如何处理单元测试产生的数据,下列哪些说法是正确的?

单项选择题 1.publicclassGoTest{2.publicstaticvoidmain(String[]args){3.Sentea=newSente();a.go();4.Gobanb=newGoban();b.go();5.Stonec=newStone();c.go();6.}7.}8.9.classSenteimplementsGo{10.publicvoidgo(){System.out.println(”goinSente.”);}11.}12.13.classGobanextendsSente{14.publicvoidgo(){System.out.println(”goinGoban”);}15.}16.17.classStoneextendsGobanimplementsGo{}18.19.interfaceGo{publicvoidgo();}Whatistheresult?()

单项选择题 publicabstractclassShape{intx;inty;publicabstractvoiddraw();publicvoidsetAnchor(intx,inty){this.x=x;this.y=y;}}andaclassCirclethatextendsandfullyimplementstheShapeclass.Whichiscorrect?()

单项选择题 interfaceData{publicvoidload();}abstractclassInfo{publicabstractvoidload();}WhichclasscorrectlyusestheDatainterfaceandInfoclass?()

判断题 Flash中的图层分为普通层、运动引导层、遮罩层和注释说明层4种。通常建立的层都是普通层。()

单项选择题 Aprogrammerisdesigningaclasstoencapsulatetheinformationaboutaninventoryitem.AJavaBeanscomponentisneededtodothis.TheInventoryltemclasshasprivateinstancevariablestostoretheiteminformation:10.privateintitemId;11.privateStringname;12.privateStringdescription;WhichmethodsignaturefollowstheJavaBeansnamingstandardsformodifyingtheitemldinstancevariable?()A.itemID(intitemId)B.update(intitemId)C.setItemId(intitemId)D.mutateItemId(intitemId)E.updateItemID(intitemId)

单项选择题 Aprogrammerneedstocreatealoggingmethodthatcanacceptanarbitrarynumberofarguments.Forexample,itmaybecalledintheseways:logIt(”logmessage1);logIt(”logmessage2”,”logmessage3”);logIt(”logmessage4”,logmessage5”,logmessage6);Whichdeclarationsatisfiesthisrequirement?()A.publicvoidlogIt(String*msgs)B.publicvoidlogIt(String[]msgs)C.publicvoidlogIt(String...msgs)D.publicvoidlogIt(Stringmsg1,Stringmsg2,Stringmsg3)

单项选择题 1.publicclassA{2.3.privateintcounter=0;4.5.publicstaticintgetInstanceCount(){6.returncounter;7.}8.9.publicA(){10.counter++;11.}12.13.}GiventhiscodefromClassB:25.Aa1=newA();26.Aa2=newA();27.Aa3=newA();28.System.out.printIn(A.getInstanceCount());Whatistheresult?()A.CompilationofclassAfails.B.Line28printsthevalue3toSystem.out.C.Line28printsthevalue1toSystem.out.D.Aruntimeerroroccurswhenline25executes.E.Compilationfailsbecauseofanerroronline28.

单项选择题 publicclassBall{publicenumColor{RED,GREEN,BLUE};publicvoidfoo(){//insertcodehere{System.out.println(c);}}}Whichcodeinsertedatline14causesthefoomethodtoprintRED,GREEN,andBLUE?()

单项选择题 publicinterfaceA{StringDEFAULT_GREETING=HelloWorld”;publicvoidmethod1();}AprogrammerwantstocreateaninterfacecalledBthathasAasitsparent.Whichinterfacedeclarationiscorrect?()

单项选择题 classTestA{publicvoidstart(){System.out.println(”TestA”);}}publicclassTestBextendsTestA{publicvoidstart(){System.out.println(”TestB”);}publicstaticvoidmain(String[]args){((TestA)newTestB()).start();}}Whatistheresult?()A.TestAB.TestBC.Compilationfails.D.Anexceptionisthrownatruntime.

单项选择题 publicclassPerson{privatename;publicPerson(Stringname){this.name=name;}publicinthashCode(){return420;}}Whichistrue?()

单项选择题 33.Dated=newDate(0);34.Stringds=December15,2004”;35.//insertcodehere36.try{37.d=df.parse(ds);38.}39.catch(ParseExceptione){40.System.out.println(”Unabletoparse+ds);41.}42.//insertcodeheretooWhichwillcreatetheappropriateDateFormatobjectandaddadaytotheDateobject?()A.35.DateFormatdf=DateFormat.getDateFormat();42.d.setTime((60*60*24)+d.getTime());B.35.DateFormatdf=DateFormat.getDateJnstance();42.d.setTime((1000*60*60*24)+d.getTime());C.35.DateFormatdf=DateFormat.getDateFormat();42.d.setLocalTime((1000*60*60*24)+d.getLocalTime());D.35.DateFormatdf=DateFormat.getDateJnstance();42.d.setLocalTime((60*60*24)+d.getLocalTime());

单项选择题 Given:ArrayLista=newArrayList();containingthevalues{1”,2”,3”,4”,5”,6”,7”,8”}Whichcodewillreturn2?()

单项选择题 34.HashMapprops=newHashMap();35.props.put(”key45”,somevalue”);36.props.put(”key12”,someothervalue”);37.props.put(”key39”,yetanothervalue”);38.Sets=props.keySet();39.//insertcodehereWhat,insertedatline39,willsortthekeysinthepropsHashMap?()A.Arrays.sort(s);B.s=newTreeSet(s);C.Collections.sort(s);D.s=newSortedSet(s);

单项选择题 Given:int[]myArray=newint[]{1,2,3,4,5};Whatallowsyoutocreatealistfromthisarray?()