多项选择题
10.publicclassBar{
11.staticvoidfoo(int...x){
12.//insertcodehere
13.}
14.}
Which two code fragments,inserted independently at line1 2,will allow the class to compile()
A.foreach(x)System.out.println(z);
B.for(intz:x)System.out.println(z);
C.while(x.hasNext())System.out.println(x.next());
D.for(inti=0;i
相关考题
-
单项选择题
String[] elements={"for","tea","too"}; String first=(elements.length>0)?elements[0]null; What is the result?()
A.Compilation fails.
B.An exception is thrown at runtime.
C.The variable first is set to null.
D.The variable first is set to elements[0]. -
单项选择题
11.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.123
B.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. -
多项选择题
Which two code fragments correctly create and initialize a static array of int elements()
A.static final int[]a={100,200};
B.static final int[]a;static{a=new int[2];a[0]=100;a[1]=200;}
C.static final int[]a=new int[2]{100,200};
D.static final int[]a;static void int(){a=new int[3];a[0]=100;a[1]=200;}
