网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
interfaceTestA{StringtoString();}2.publicclassTest{3.publicstaticvoidmain(String[]args){4.System.out.println(newTestA(){5.publicStringtoString(){returntest”;}6.}7.}8.}Whatistheresult?()
A.test
B.null
C.Anexceptionisthrownatruntime.
D.Compilationfailsbecauseofanerrorinline1.
E.Compilationfailsbecauseofanerrorinline4.
F.Compilationfailsbecauseofanerrorinline5.
参考答案
更多 “ interfaceTestA{StringtoString();}2.publicclassTest{3.publicstaticvoidmain(String[]args){4.System.out.println(newTestA(){5.publicStringtoString(){returntest”;}6.}7.}8.}Whatistheresult?() A.testB.nullC.Anexceptionisthrownatruntime.D.Compilationfailsbecauseofanerrorinline1.E.Compilationfailsbecauseofanerrorinline4.F.Compilationfailsbecauseofanerrorinline5. ” 相关考题
考题
Given1.publicclassFoo{2.publicstaticvoidmain(String[]args)}3.try{return;}4.finally{Syste.out.printIn(Finally”);}5.}6.}Whatistheresult()?
A.Theprogramrunsandprintsnothing.B.Theprogramrunsandprints“Finally”.C.Thecodecomiles.Butanexceptionisthrownatruntime.D.Thecodewillnotcompilebecausethecatchblockismissing.
考题
importjava.util.*;2.publicclassTest{3.publicstaticvoidmain(String[]args){4.Liststrings=newArrayList();5.//insertcodehere6.}7.}Whichfour,insertedatline5,willallowcompilationtosucceed?()
A.Strings=strings.get(0);B.Iteratori1=strings.iterator();C.String[]array1=strings.toArray();D.Iteratori2=strings.iterator();E.String[]array2=strings.toArray(newString[1]);F.Iteratori3=strings.iterator();
考题
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
考题
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?()
考题
publicclassFooimplementsRunnable(3.publicvoidrun(Threadt){4.system.out.printIn(Running.”);5.}6.publicstaticvoidmain(String[]args){7.newthread(newFoo()).start();8.)9.)Whatistheresult?()
A.Anexceptionisthrown.B.Theprogramexistswithoutprintinganything.C.Anerroratline1causescompilationtofail.D.Anerroratline6causesthecompilationtofail.E.“Running”isprintedandtheprogramexits.
考题
publicclassArrayTest{2.publicstaticvoidmain(String[]args){3.floatf1[],f2[];4.f1=newfloat[10];5.f2=f1;6.System.out.printIn(f2[0]=”+f2[0]);7.}8.}Whatistheresult?()
A.Itprintsf2[0]=0.0B.Itprintsf2[0]=NaNC.Anerroratline5causescompiletofail.D.Anerroratline6causescompiletofail.E.Anerroratline6causesanexceptionatruntime.
考题
publicclassTest{publicstaticvoidmain(String[]args){Stringstr=NULL;System.out.println(str);}}Whatistheresult?()
A.NULLB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.
考题
publicclassA{2.voidA(){3.System.out.println(ClassA”);4.}5.publicstaticvoidmain(String[]args){6.newA();7.}8.}Whatistheresult?()
A.ClassAB.Compilationfails.C.Anexceptionisthrownatline2.D.Anexceptionisthrownatline6.E.Thecodeexecuteswithnooutput.
考题
publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?()
A.FinallyB.Compilationfails.C.Thecoderunswithnooutput.D.Anexceptionisthrownatruntime.
热门标签
最新试卷