单项选择题

A.Thecodewillcompilewithoutchanges.
B.ThecodewillcompileifpublicTree(){Plant();}isaddedtotheTreeclass.
C.ThecodewillcompileifpublicPlant(){Tree();}isaddedtothePlantclass.
D.ThecodewillcompileifpublicPlant(){this(”fern”);}isaddedtothePlantclass.
E.ThecodewillcompileifpublicPlant(){Plant(”fern”);}isaddedtothePlantclass.
相关考题

单项选择题 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.

单项选择题 1.publicclassa{2.publicvoidmethod1(){3.try{4.Bb=newb();5.b.method2();6.//morecodehere7.}catch(TestExceptionte){8.thrownewRuntimeException(te);9.}10.}11.}1.publicclassb{2.publicvoidmethod2()throwsTestException{3.//morecodehere4.}5.}1.publicclassTestExceptionextendsException{2.}Given:31.publicvoidmethod(){32.Aa=newa();33.a.method1();34.}WhichistrueifaTestExceptionisthrownonline3ofclassb?()

单项选择题 publicstaticvoidmain(String[]args){try{args=null;args[0]=test”;System.out.println(args[0]);}catch(Exceptionex){System.out.println(”Exception”);}catch(NullPointerExceptionnpe){System.out.println(”NullPointerException”);}}Whatistheresult?()A.testB.ExceptionC.Compilationfails.D.NullPointerException

单项选择题 Giventhismethodinaclass:publicStringtoString(){StringBufferbuffer=newStringBuffer();buffer.append(?<?);buffer.append(this.name);buffer.append(?>?);returnbuffer.toString();}Whichistrue?()