现有: 3. import java.util.*; 4. class ForInTest { 5.static List list=new ArrayList(); 6. 7.public static void main (String [] args) { 8.list. add("a"); list. add("b");list. add( "c"); 9. //insert code here 10. System.out.print (o); 11. } 12. } 哪一行插入到第9行将导致输出“abc"?()
第1题:
1. import java.util.*; 2. class ForInTest { 3. static List list = new ArrayList(); 4. 5. static List getList() { return list; } 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. // insert code here 10. System.out.print(o); 11. } 12. } 第 9 行插入哪一项将输出 abc?()
第2题:
现有: 1. import java.util.*; 2. class ForInTest { 3.static List list - new ArrayList(): 4. 5.static List getList() { return list; } 6. 7.public static void main (Strincj[] args) { 8.list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print (o); 11. } 12. } 第9行插入哪一项将输出abc?()
第3题:
import java.util.*; public class NameList { private List names = new ArrayList(); public synchronized void add(String name) { names.add(name); } public synchronized void printAll() { for (int i = 0; i
第4题:
1. import java.util.*; 2. public class Example { 3. public static void main(String[] args) { 4. // insert code here 5. set.add(new integer(2)); 6. set.add(new integer(l)); 7. System.out.println(set); 8. } 9. } Which code, inserted at line 4, guarantees that this program will output [1,2]? ()
第5题:
1. import java.util.*; 2. public class Test { 3. public static void main(String[] args) { 4. List
第6题:
现有: 3. import java.util.*; 4. class ForInTest { 5. static List list = new ArrayList(); 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print(o); 11. } 12. } 哪一行插入到第9行将导致输出“abc”?()
第7题:
An exception may be thrown at runtime.
The code may run with no output, without exiting.
The code may rum with output “A B A B C C “, then exit.
The code may ruin with output “A A A B C A B C C “, then exit.
The code may rum with output “A B C A B C A B C “, then exit.
The code may ruin with output “A B C A A B C A B C “, then exit.
第8题:
Set set = new TreeSet();
Set set = new HashSet();
Set set = new SortedSet();
List set = new SortedList();
Set set = new LinkedHashSet();
第9题:
for(char o: list)
for(Object o: getList())
for(Object o: getList();)
for(Object o: o.getList())
第10题:
Compilation fails.
aAaA aAa AAaa AaA
AAaa AaA aAa aAaA
AaA AAaa aAaA aAa
aAa AaA aAaA AAaa
An exception is thrown at runtime.
第11题:
只在第11行
在第8行和第11行
在第5行、第8行和第11行
在第2行、第5行、第8行和第11行
第12题:
one
one three two
one two three
one two three four
four one three two
编译失败
第13题:
现有: import java.util.*; class AddStuff2 { public static void main(String [] args) { TreeSet
第14题:
现有 public class Demo{ public static void main (String[] args){ List al=new ArrayList(); a1.add("l"); a1.add("2"); a1.add("2"); a1.add("3"); System.out.println (al); } } 上述程序执行后的输出是哪项?()
第15题:
public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator(); } public static void main(String[] args) { List list = new ArrayList(); list.add(” 1”); list.add(”2”); list.add(”3”); for (Object obj: reverse(list)) System.out.print(obj + “,”); } What is the result?()
第16题:
现有: 1. import java.util.*; 2. 3. Class FindStuff { 4.public static void main (String[]args) { 5, //insert code here 6. c.put ("X", 123); 7. } 8. } 分别插入到第5行,哪三行允许代码编译?()
第17题:
3. import java.util.*; 4. class ForInTest { 5. static List list = new ArrayList(); 6. 7. public static void main(String [] args) { 8. list.add("a"); list.add("b"); list.add("c"); 9. //insert code here 10. System.out.print(o); 11. } 12. } 哪一行插入到第9行将导致输出“abc”?()
第18题:
String s = strings.get(0);
Iterator i1 = strings.iterator();
String[] array1 = strings.toArray();
Iterator
String[] array2 = strings.toArray(new String[1]);
Iterator
第19题:
3,2,1,
1,2,3,
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
第20题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第21题:
只有s1
只有s3
只有s1和s3
只有s1和s4
第22题:
Map c= new SortedMap();
HashMap c= new HashMap();
HashMap c= new Hashtalole();
SortedMap c= new TreeMap();
ArrayList c= new ArrayList();
MaD c = new LinkedHashMap();
第23题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )