1.importjava.util.*;2.classForInTest{3.staticListlist=newArrayList();4.5.staticListgetList(){returnlist;}6.7.publicstaticvoidmain(String[]args){8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);11.}12.}第9行插入哪一项将输出abc?()A.for(charo:list)B.for(Objecto:getList())C.for(Objecto:getList();)D.for(Objecto:o.getList())

1.importjava.util.*;2.classForInTest{3.staticListlist=newArrayList();4.5.staticListgetList(){returnlist;}6.7.publicstaticvoidmain(String[]args){8.list.add("a");list.add("b");list.add("c");9.//insertcodehere10.System.out.print(o);11.}12.}第9行插入哪一项将输出abc?()

A.for(charo:list)

B.for(Objecto:getList())

C.for(Objecto:getList();)

D.for(Objecto:o.getList())


相关考题:

现有:1.importjava.util.*; 现有:1.importjava.util.*;2.classForInTest{3.staticListlist-newArrayList():4.5.staticListgetList(){returnlist;}6.7.publicstaticvoidmain(Strincj[]args){8.list.add(a);list.add(b);list.add(c);9.//insertcodehere10.System.out.print(o);11.}12.}第9行插入哪一项将输出abc?()

importjava.util.*;publicclassLetterASort{publicstaticvoidmain(String[]args){ArrayListstrings=newArrayList();strings.add(?aAaA”);strings.add(”AaA”);strings.add(?aAa”);strings.add(”AAaa”);Collections.sort(strings);for(Strings:strings){System.out.print(s+);}}}Whatistheresult?()A.Compilationfails.B.aAaAaAaAAaaAaAC.AAaaAaAaAaaAaAD.AaAAAaaaAaAaAaE.aAaAaAaAaAAAaaF.Anexceptionisthrownatruntime.

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();

importjava.util.*;publicclassNameList{privateListnames=newArrayList();publicsynchronizedvoidadd(Stringname){names.add(name);}publicsynchronizedvoidprintAll(){for(inti=0;iSystem.out.print(names.get(i)+);}}publicstaticvoidmain(String[]args){finalNameListsl=newNameList();for(inti=0;i2;i++){newThread(){publicvoidruin(){sl.add(”A”);sl.add(”B”);sl.add(”C”);sl.printAll();}}.start();}}}Whichtwostatementsaretrueifthisclassiscompiledandrun?()

定义一个List对象list,使用ArrayList的构造方法进行初始化,并且要求list中必须全部存放Integer类型的对象,以下语句正确的是()。A.List list = new ArrayList<Integer>();B.List list = new ArrayList ();C.List<Integer> list = new ArrayList<Integer>();D.ArrayList<Integer> list = new List<Integer>();

定义一个List对象list,使用ArrayList的构造方法进行初始化,并且要求list中必须全部存放Integer类型的对象,以下语句正确的是()。A.List list = new ArrayList ();B.List list = new ArrayList<Integer>();C.ArrayList<Integer> list = new List<Integer>();D.List<Integer> list = new ArrayList<Integer>();

创建一个只能存放String的泛型ArrayList的语句是哪项?()A.ArrayList<int> al=new ArrayList<int>();B.ArrayList<String> al=new ArrayList<String>();C.ArrayList al=new ArrayList();D.ArrayList al =new List();

创建一个只能存放String的泛型ArrayList的语句是哪项?A.ArrayList<String> al=new ArrayList<>();B.ArrayList al=new ArrayList<>();C.ArrayList al=new ArrayList();D.ArrayList al=new List();

若要创建用于存储整数的列表,请使用A.ArrayList<Object> list = new ArrayList<>();B.ArrayList<Integer> list = new ArrayList<>();C.ArrayList<int> list = new ArrayList<int>();D.ArrayList<Number> list = new ArrayList<>();