publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}Whatistheresult?() A.123B.Compilationfailsbecauseofanerrorinline12.C.Compilationfailsbecauseofanerrorinline13.D.Compilationfailsbecauseofanerrorinline14.E.AClassCastExceptionisthrownatruntime.

publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}Whatistheresult?()

A.123

B.Compilationfailsbecauseofanerrorinline12.

C.Compilationfailsbecauseofanerrorinline13.

D.Compilationfailsbecauseofanerrorinline14.

E.AClassCastExceptionisthrownatruntime.


相关考题:

下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i,String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String[]args){ print(99,"Int first"); } }A.String:String first,int:11B.int:11,String:Int firstC.String:String first,int99D.int:99,String:Int first

public static void main(String[]args){12.Object obj=new int[]{1,2,3};13.int[] someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+)15.}What is the result?() A.123B.Compilation fails because of an error in line 12.C.Compilation fails because of an error in line 13.D.Compilation fails because of an error in line 14.E.A ClassCastException is thrown at runtime.

publicstaticIteratorreverse(Listlist){Collections.reverse(list);returnlist.iterator();}publicstaticvoidmain(String[]args){Listlist=newArrayList();list.add(”1”);list.add(”2”);list.add(”3”);for(Objectobj:reverse(list))System.out.print(obj+,”);}Whatistheresult?()A.3,2,1,B.1,2,3,C.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.

publicstaticvoidmain(String[]args){12.Objectobj=newObject(){13.publicinthashCode(){14.returns42;15.}16.};17.System.out.println(obj.hashCode());18.}Whatistheresult?() A.42B.Anexceptionisthrownatruntime.C.Compilationfailsbecauseofanerroronline12.D.Compilationfailsbecauseofanerroronline16.E.Compilationfailsbecauseofanerroronline17.

publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){thrownewRuntimeException();}}Whatistheresult?()A.ABB.BCC.ABCD.BCDE.Compilationfails.

publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){}}Whatistheresult?()A.ACB.BDC.ACDD.ABCDE.Compilationfails.

classBase{Base(){System.out.print(Base”);}}publicclassAlphaextendsBase{publicstaticvoidmain(String[]args){newAlpha();newBase();}}Whatistheresult?() A.BaseB.BaseBaseC.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.

Given:11.publicstaticvoidmain(String[]args){12.Objectobj=newint[]{1,2,3};13.int[]someArray=(int[])obj;14.for(inti:someArray)System.out.print(i+);15.}Whatistheresult?() A.Compilationfailsbecauseofanerrorinline13.B.AClassCastExceptionisthrownatruntime.C.123D.Compilationfailsbecauseofanerrorinline14.E.Compilationfailsbecauseofanerrorinline12.

下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }A.String:Stringfirst,int:11B.int:11,String:Int firstC.String:String first,int:99D.int:99,String:int first

下列程序运行的输出结果是________ public class Test { public static void main(String[] args) { for(int i=1;i<=10;i++) { if(i<=5) continue; System.out.print(i+" "); } } }A.1 2 3 4B.1 2 3 4 5 6 7 8 9 10C.6 7 8 9D.6 7 8 9 10