单项选择题

A.publicstaticvoidmain(String[]args){12.Integeri=uewInteger(1)+newInteger(2);13.switch(i){14.case3:System.out.println(”three”);break;15.default:System.out.println(”other”);break;16.}17.}Whatistheresult?()
A.three
B.other
C.Anexceptionisthrownatruntime.
D.Compilationfailsbecauseofanerroronline12.
E.Compilationfailsbecauseofanerroronline13.
F.Compilationfailsbecauseofanerroronline15.
相关考题

单项选择题 10.classLine{11.publicclassPoint{publicintx,y;}12.publicPointgetPoint(){returnnewPoint();}13.}14.classTriangle{15.publicTriangle(){16.//insertcodehere17.}18.}Whichcode,insertedatline16,correctlyretrievesalocalinstanceofaPointobject?()A.Pointp=Line.getPoint();B.Line.Pointp=Line.getPoint();C.Pointp=(newLine()).getPoint();D.Line.Pointp=(newLine()).getPoint();

单项选择题 publicclassTest{publicenumDogs{collie,harrier};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.collie;switch(myDog){casecollie:System.out.print(”collie);caseharrier:System.out.print(”harrier);}}}Whatistheresult?()A.collieB.harrierC.Compilationfails.D.collieharrierE.Anexceptionisthrownatruntime.

单项选择题 publicclassPlant{privateStringname;publicPlant(Stringname){this.name=name;}publicStringgetName(){returnname;}}publicclassTreeextendsPlant{publicvoidgrowFruit(){}publicvoiddropLeaves(){}}Whichistrue?()

单项选择题 publicclassTest{publicenumDogs{collie,harrier,shepherd};publicstaticvoidmain(String[]args){DogsmyDog=Dogs.shepherd;switch(myDog){casecollie:System.out.print(”collie);casedefault:System.out.print(”retriever);caseharrier:System.out.print(”harrier);}}}Whatistheresult?()A.harrierB.shepherdC.retrieverD.Compilationfails.E.retrieverharrierF.Anexceptionisthrownatruntime.

单项选择题 publicclassBootchy{intbootch;Stringsnootch;publicBootchy(){this(”snootchy”);System.out.print(”first);}publicBootchy(Stringsnootch){this(420,snootchy”);System.out.print(”second);}publicBootchy(intbootch,Stringsnootch){this.bootch=bootch;this.snootch=snootch;System.out.print(”third);}publicstaticvoidmain(String[]args){Bootchyb=newBootchy();System.out.print(b.snootch++b.bootch);}}Whatistheresult?()A.snootchy420thirdsecondfirstB.snootchy420firstsecondthirdC.firstsecondthirdsnootchy420D.thirdsecondfirstsiiootchy420E.thirdfirstsecondsnootchy420F.firstsecondfirstthirdsnootchy420

单项选择题 Whencomparingjava.io.BufferedWritertojava.io.FileWriter,whichcapabilityexistsasamethodinonlyoneofthetwo?()

单项选择题 importjava.io.*;publicclassForestimplementsSerializable{privateTreetree=newTree();publicstaticvoidmain(String[]args){Forestf=newForest();try{FileOutputStreamfs=newFileOutputStream(”Forest.ser”);ObjectOutputStreamos=newObjectOutputStream(fs);os.writeObject(f);os.close();}catch(Exceptionex){ex.printStackTrace();}}}classTree{}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.AninstanceofForestisserialized.D.AinstanceofForestandaninstanceofTreearebothserialized.

单项选择题 借记卡属于()。

单项选择题 publicclassYikes{publicstaticvoidgo(Longn){System.out.println(”Long);}publicstaticvoidgo(Shortn){System.out.println(”Short);}publicstaticvoidgo(intn){System.out.println(”int);}publicstaticvoidmain(String[]args){shorty=6;longz=7;go(y);go(z);}}Whatistheresult?()A.intLongB.ShortLongC.Compilationfails.D.Anexceptionisthrownatruntime.

单项选择题 publicclassWow{publicstaticvoidgo(shortn){System.out.println(”short”);}publicstaticvoidgo(Shortn){System.out.println(”SHORT”);}publicstaticvoidgo(Longn){System.out.println(”LONG”);}publicstaticvoidmain(String[]args){Shorty=6;intz=7;go(y);go(z);}}Whatistheresult?()A.shortLONGB.SHORTLONGC.Compilationfails.D.Anexceptionisthrownatruntime.

单项选择题 Datedate=newDate();13.df.setLocale(Locale.ITALY);14.Strings=df.format(date);ThevariabledfisanobjectoftypeDateFormatthathasbeeninitializedinline11.WhatistheresultifthiscodeisrunonDecember14,2000?()

单项选择题 1.importjava.io.*;2.publicclassFooimplementsSerializable{3.publicintx,y;4.publicFoo(intx,inty){this.x=x;this.y=y;}5.6.privatevoidwriteObject(ObjectOutputStreams)7.throwsIOException{8.s.writeInt(x);s.writeInt(y)9.}10.11.privatevoidreadObject(ObjectInputStreams)12.throwsIOException,ClassNotFoundException{13.14.//insertcodehere15.16.}17.}Whichcode,insertedatline14,willallowthisclasstocorrectlyserializeand deserialize?()

单项选择题 AssumingthattheserializeBanana2()andthedeserializeBanana2()methodswillcorrectlyuseJavaserializationandgiven:importjava.io.*;classFood{Food(){System.out.print(”1”);}}classFruitextendsFoodimplementsSerializable{Fruit(){System.out.print(”2”);}}publicclassBanana2extendsFruit{intsize=42;publicstaticvoidmain(String[]args){Banana2b=newBanana2();b.serializeBanana2(b);//assumecorrectserializationb=b.deserializeBanana2(b);//assumecorrectSystem.out.println(”restored+b.size+);}//moreBanana2methods}Whatistheresult?()

单项选择题 10.publicclassFooimplementsjava.io.Serializable{11.privateintx;12.publicintgetX(){returnx;}12.publicFoo(intx){this.x=x;}13.privatevoidwriteObject(ObjectOutputStreams)14.throwsIOException{15.//insertcodehere16.}17.}Whichcodefragment,insertedatline15,willallowFooobjectstobecorrectlyserializedanddeserialized?()A.s.writeInt(x);B.s.serialize(x);C.s.writeObject(x);D.s.defaultWriteObject();

判断题 通信管道与通道的建设应较相关市政地下管线之前进行建设。()

单项选择题 publicvoidsomeMethod(Objectvalue){12.//checkfornullvalue....20.System.out.println(value.getClass());21.}What,insertedatline12,istheappropriatewaytohandleanullvalue?()

单项选择题 staticvoidtest()throwsRuntimeException{try{System.out.print(”test);thrownewRuntimeException();}catch(Exceptionex){System.out.print(”exception);}}publicstaticvoidmain(String[]args){try{test();}catch(RuntimeExceptionex){System.out.print(”runtime);}System.out.print(”end);}Whatistheresult?()A.testendB.Compilationfails.C.testruntimeendD.testexceptionendE.AThrowableisthrownbymainatruntime.

单项选择题 11.staticclassA{12.voidprocess()throwsException{thrownewException();}13.}14.staticclassBextendsA{15.voidprocess(){System.out.println(”B”);}16.}17.publicstaticvoidmain(String[]args){18.newB().process();19.}Whatistheresult?()A.BB.Thecoderunswithnooutput.C.Compilationfailsbecauseofanerrorinline12.D.Compilationfailsbecauseofanerrorinline15.E.Compilationfailsbecauseofanerrorinline18.

单项选择题 staticvoidtest()throwsError{if(true)thrownewAssertionError();System.out.print(”test);}publicstaticvoidmain(String[]args){try{test();}catch(Exceptionex){System.out.print(”exception);}System.out.print(”elld);}Whatistheresult?()A.endB.Compilationfails.C.exceptionendD.exceptiontestendE.AThrowableisthrownbymain.F.AnExceptionisthrownbymain.

单项选择题 84.try{85.ResourceConnectioncon=resourceFactory.getConnection();86.Resultsr=con.query(”GETINFOFROMCUSTOMER”);87.info=r.getData();88.con.close();89.}catch(ResourceExceptionre){90.errorLog.write(re.getMessage());91.}92.returninfo;WhichistrueifaResourceExceptionisthrownonline86?()A.Line92willnotexecute.B.Theconnectionwillnotberetrievedinline85.C.Theresourceconnectionwillnotbeclosedonline88.D.Theenclosingmethodwillthrowanexceptiontoitscaller.