相关考题

单项选择题 11.classa{12.publicvoidprocess(){System.out.print(”a,”);}}13.classbextendsa{14.publicvoidprocess()throwsIOException{15.super.process();16.System.out.print(”b,”);17.thrownewIOException();18.}}19.publicstaticvoidmain(String[]args){20.try{newb().process();}21.catch(IOExceptione){System.out.println(”Exception”);}}Whatistheresult?()A.ExceptionB.a,b,ExceptionC.Compilationfailsbecauseofanerrorinline20.D.Compilationfailsbecauseofanerrorinline14.E.ANullPointerExceptionisthrownatruntime.

单项选择题 publicclassAssertStuff{publicstaticvoidmain(String[]args){intx=5;inty=7;assert(x>y):stuff”;System.out.println(”passed”);}}Andthesecommandlineinvocations:javaAssertStuffjava-eaAssertStuffWhatistheresult?()A.passedstuffB.stuffpassedC.passed AnAssertionErroristhrownwiththeword“stuff”addedtothestacktrace.D.passed AnAssertionErroristhrownwithouttheword“stuff”addedtothestacktrace.E.passed AnAssertionExceptionisthrownwiththeword“stuff”addedtothestacktrace.F.passed AnAssertionExceptionisthrownwithouttheword“stuff”addedtothestacktrace.

单项选择题 23.intz=5;24.25.publicvoidstuff1(intx){26.assert(x>0);27.switch(x){28.case2:x=3;29.default:assertfalse;}}30.31.privatevoidstuff2(inty){assert(y<0);}32.33.privatevoidstuff3(){assert(stuff4O);}34.35.privatebooleanstuff4(){z=6;returnfalse;}Whichistrue?()A.Alloftheassertstatementsareusedappropriately.B.Onlytheassertstatementonline31isusedappropriately.C.Theassertstatementsonlines29and31areusedappropriately.D.Theassertstatementsonlines26and29areusedappropriately.E.Theassertstatementsonlines29and33areusedappropriately.F.Theassertstatementsonlines29,31,and33areusedappropriately.G.Theassertstatementsonlines26,29,and31areusedappropriately.

单项选择题 11.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.threeB.otherC.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?()