for (Iterator o : list.iterator(); o.hasNext (); )
for (Iterator 0 : list)
for (Object o : list.iterator())
for (Object o : list)
第1题:
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()
第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(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?()
第3题:
现有: 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?()
第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题:
for(char o: list)
for (Object o: o.getList())
for(Object o: getList();)
for(Object o: getList())
for(Object o: o.getList();)
第8题:
Compilation fails.
Cannot add Toppings
The code runs with no output.
A NullPointerException is thrown in Line 4.
第9题:
Set set = new TreeSet();
Set set = new HashSet();
Set set = new SortedSet();
List set = new SortedList();
Set set = new LinkedHashSet();
第10题:
for(char o: list)
for(Object o: getList())
for(Object o: getList();)
for(Object o: o.getList())
第11题:
Compilation fails.
aAaA aAa AAaa AaA
AAaa AaA aAa aAaA
AaA AAaa aAaA aAa
aAa AaA aAaA AAaa
An exception is thrown at runtime.
第12题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第13题:
1. class Pizza { 2. java.util.ArrayList toppings; 3. public final void addTopping(String topping) { 4. toppings.add(topping); 5. } 6. } 7. public class PepperoniPizza extends Pizza { 8. public void addTopping(String topping) { 9. System.out.println(”Cannot add Toppings”); 10. } 11. public static void main(String[] args) { 12. Pizza pizza = new PepperoniPizza(); 13. pizza.addTopping(”Mushrooms”); 14. } 15. } What is the result?()
第14题:
现有: import java.util.*; class AddStuff2 { public static void main(String [] args) { TreeSet
第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 (Iterator o : list.iterator(); o.hasNext (); )
for (Iterator 0 : list)
for (Object o : list.iterator())
for (Object o : list)
第21题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第22题:
只有s1
只有s3
只有s1和s3
只有s1和s4
第23题:
for(Object o : list)
for(Iterator o : list)
for(Object o : list.iterator())
for(Iterator o : list.iterator(); o.hasNext (); )
第24题:
one
one three two
one two three
one two three four
four one three two
编译失败