单项选择题

A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesnormallyandprints“bar”.
D.Thecodeexecutesnormally,butnothingprints.
相关考题

单项选择题 10.publicclassSuperCaic{11.protectedstaticintmultiply(inta,intb){returna*b;}12.}and:20.publicclassSubCalcextendsSuperCalc{21.publicstaticintmultiply(inta,intb){22.intc=super.multiply(a,b);23.returnc;24.}25.}and:30.SubCalcsc=newSubCalc();31.System.out.println(sc.multiply(3,4));32.System.out.println(SubCalc.multiply(2,2));Whatistheresult?()A.124B.Thecoderunswithnooutput.C.Anexceptionisthrownatruntime.D.Compilationfailsbecauseofanerrorinline21.E.Compilationfailsbecauseofanerrorinline22.F.Compilationfailsbecauseofanerrorinline31.

单项选择题 importjava.util.*;publicclassPQ{publicstaticvoidmain(String[]args){PriorityQueuepq=newPriorityQueue();pq.add(”carrot”);pq.add(”apple”);pq.add(”banana”);System.out.println(pq.poll()+”:”+pq.peek());}}Whatistheresult?()A.apple:appleB.carrot:appleC.apple:bananaD.banana:appleE.carrot:carrotF.carrot:banana

单项选择题 1.importjava.util.*;2.publicclassTestSet{3.enumExample{ONE,TWO,THREE}4.publicstaticvoidmain(String[]args){5.Collectioncoll=newArrayList();6.coll.add(Example.THREE);7.coll.add(Example.THREE);8.coll.add(Example.THREE);9.coll.add(Example.TWO);10.coll.add(Example.TWO);11.coll.add(Example.ONE);12.Setset=newHashSet(coll);13.}14.}Whichstatementistrueaboutthesetvariableonline12?()A.Thesetvariablecontainsallsixelementsfromthecollcollection,andtheorderisguaranteedtobepreserved.B.Thesetvariablecontainsonlythreeelementsfromthecollcollection,andtheorderisguaranteedtobepreserved.C.Thesetvariablecontainsallsixelementsfromthecoilcollection,buttheorderisNOTguaranteedtobepreserved.D.Thesetvariablecontainsonlythreeelementsfromthecoilcollection,buttheorderisNOTguaranteedtobepreserved.

单项选择题 1.interfaceA{publicvoidaMethod();}2.interfaceB{publicvoidbMethod();}3.interfaceCextendsA,B{publicvoidcMethod();}4.classDimplementsB{5.publicvoidbMethod(){}6.}7.classEextendsDimplementsC{8.publicvoidaMethod(){}9.publicvoidbMethod(){}10.publicvoidcMethod(){}11.}Whatistheresult?()A.Compilationfailsbecauseofanerrorinline3.B.Compilationfailsbecauseofanerrorinline7.C.Compilationfailsbecauseofanerrorinline9.D.IfyoudefineDe=newE(),thene.bMethod()invokestheversionofbMethod()definedinLine5.E.IfyoudefineDe=(D)(newE()),thene.bMethod()invokestheversionofbMethod()definedinLine5.F.IfyoudefineDe=(D)(newE()),thene.bMethod()invokestheversionofbMethod()definedinLine9.

单项选择题 11.classAnimal{publicStringnoise(){returnpeep”;}}12.classDogextendsAnimal{13.publicStringnoise(){returnbark”;}14.}15.classCatextendsAnimal{16.publicStringnoise(){returnmeow”;}17.}.....30.Animalanimal=newDog();31.Catcat=(Cat)animal;32.System.out.printIn(cat.noise());Whatistheresult?()A.peepB.barkC.meowD.Compilationfails.E.Anexceptionisthrownatruntime.

单项选择题 11.abstractclassVehicle{publicintspeed(){return0;}}12.classCarextendsVehicle{publicintspeed(){return60;}}13.classRaceCarextendsCar{publicintspeed(){return150;}}......21.RaceCarracer=newRaceCar();22.Carcar=newRaceCar();23.Vehiclevehicle=newRaceCar();24.System.out.println(racer.speed()+,?+car.speed()25.+,+vehicle.speed());Whatistheresult?()A.0,0,0B.150,60,0C.Compilationfails.D.150,150,150E.Anexceptionisthrownatruntime.

单项选择题 10.publicclassHello{11.Stringtitle;12.intvalue;13.publicHello(){14.title+=World”;15.}16.publicHello(intvalue){17.this.value=value;18.title=Hello”;19.Hello();20.}21.}and:30.Helloc=newHello(5);31.System.out.println(c.title);Whatistheresult?()A.HelloB.HelloWorldC.Compilationfails.D.HelloWorld5E.Thecoderunswithnooutput.F.Anexceptionisthrownatruntime.

单项选择题 classClassA{publicintnumberOfinstances;protectedClassA(intnumberOfinstances){this.numberOflnstances=numberOfinstances;}}publicclassExtendedAextendsClassA{privateExtendedA(intnumberOfinstances){super(numberOflnstances);}publicstaticvoidmain(String[]args){ExtendedAext=newExtendedA(420);System.out.print(ext.numberOflnstances);}}Whichistrue?()A.420istheoutput.B.Anexceptionisthrownatruntime.C.Allconstructorsmustbedeclaredpublic.D.ConstructorsCANNOTusetheprivatemodifier.E.ConstructorsCANNOTusetheprotectedmodifier.

单项选择题 publicclassBase{publicstaticfinalStringFOO=foo”;publicstaticvoidmain(String[]args){Baseb=newBase();Subs=newSub();System.out.print(Base.FOO);System.out.print(Sub.FOO);System.out.print(b.FOO);System.out.print(s.FOO);System.out.print(((Base)s).FOO);}}classSubextendsBase{publicstaticfinalStringFOO=bar;}Whatistheresult?()A.foofoofoofoofooB.foobarfoobarbarC.foobarfoofoofooD.foobarfoobarfooE.barbarbarbarbarF.foofoofoobarbarG.foofoofoobarfoo

单项选择题 classDemoApp{publicstaticvoidmain(String[]args){intx=5;inty=++x+x++;System.out.println(y=”+y+”,x=”+x);}}以上程序运行后的输出结果是哪项?()

单项选择题 Youarebuildingyourownlayoutmechanismbyincludingdynamiccontentforthepage’sheaderandfootersections.Thefooterisalwaysstatic,buttheheadergeneratesthe<title>tagthatrequiresthepagenametobespecifieddynamicallywhentheheaderisimported.WhichJSPcodesnippetperformstheimportoftheheadercontent?()A.<jsp:includepage=’/WEB-INF/jsp/header.jsp’><jsp:paramname=’pageName’value=’WelcomePage’/></jsp:include>B.<jsp:importpage=’/WEB-INF/jsp/header.jsp’><jsp:paramname=’pageName’value=’WelcomePage’/></jsp:import>C.<jsp:includepage=’/WEB-INF/jsp/header.jsp’><jsp:attributename=’pageName’value=’WelcomePage’/>.</jsp:include>D.<jsp:importpage=’/WEB-INF/jsp/header.jsp’>.<jsp:attributename=’pageName’value=’WelcomePage’/>.</jsp:import>

单项选择题 WhichisabenefitofprecompilingaJSPpage?()

单项选择题 TheJSPdeveloperwantsacommenttobevisibleinthefinaloutputtothebrowser.WhichcommentstyleneedstobeusedinaJSPpage?()

单项选择题 WhichensuresthataJSPresponseisoftype'text/plain'?()

单项选择题 WhichHttpSessionmethodstoresanobjectinasession?()

单项选择题 ACompany.comdeveloperisdesigningamulti-tierwebapplicationanddiscoversaneedtohidethedetailsofestablishingandmaintainingremotecommunicationsfromtheclient.Inaddition,becausethebusinessandresourcetiersaredistributed,theapplicationneedstominimizetheinter-tiernetworktrafficrelatedtoservicingclientrequests.Whichdesignpatterns,workingtogether,addresstheseissues?()A.FrontControllerandTransferObjectB.FrontControllerandServiceLocatorC.BusinessDelegateandTransferObjectD.BusinessdelegateandInterceptingFilterE.Model-View-ControllerandInterceptingFilter

单项选择题 Whichinterfacemustasessionattributeimplementifitneedstobenotifiedwhenawebcontainerpersistsasession?()

单项选择题 AwebapplicationusestheHttpSessionmechanismtodetermineifauseris"loggedin."Whenausersuppliesavalidusernameandpassword,anHttpSessioniscreatedforthatuser.Theuserhasaccesstotheapplicationforonly15minutesafterloggingin.Thecodemustdeterminehowlongtheuserhasbeenloggedin,andifthistimeisgreaterthan15minutes,mustdestroytheHttpSession.Whichmethodin HttpSessionisusedtoaccomplishthis?()A.GetcreationtimeB.InvalidateafterC.GetlastaccessedtimeD.Getmaxinactiveinterval

单项选择题 GivenanHttpServletRequestrequestandanHttpServletResponseresponse:41.HttpSessionsession=null;42.//insertcodehere43.if(session==null){44.//dosomethingifsessiondoesnotexist45.}else{46.//dosomethingifsessionexists47.}Toimplementthedesignintent,whichstatementmustbeinsertedatline42?()A.session=response.getSession();B.session=request.getSession();C.session=request.getSession(true);D.session=request.getSession(false);E.session=request.getSession("jsessionid");

单项选择题 WhichmethodmustbeusedtoencodeaURLpassedasanargumenttoHttpServletResponse.sendRedirectwhenusingURLrewritingforsessiontracking?()