网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
现有:  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"?()
A

  for (Iterator o  :  list.iterator();  o.hasNext  ();  )

B

  for (Iterator 0  :  list)

C

  for (Object o  :  list.iterator())

D

  for (Object o  :  list)


参考答案

参考解析
解析: 暂无解析
更多 “单选题现有:  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"?()A   for (Iterator o  :  list.iterator();  o.hasNext  ();  )B   for (Iterator 0  :  list)C   for (Object o  :  list.iterator())D   for (Object o  :  list)” 相关考题
考题 1. import java.util.*;  2. class SubGen {  3. public static void main(String [] args) {  4. //insert code here  5. }  6. }  class Alpha { }  class Beta extends Alpha { }  class Gamma extends Beta { }  和四段代码片段:  s1. ArrayList〈? extends Alpha〉 list1 = new ArrayList〈Gamma〉();  s2. ArrayList〈Alpha〉 list2 = new ArrayList〈? extends Alpha〉();  s3. ArrayList〈? extends Alpha〉 list3 = new ArrayList〈? extends Beta〉();  s4. ArrayList〈? extends Beta〉 list4 = new ArrayList〈Gamma〉(); ArrayList〈? extends Alpha〉 list5 = list4;  哪些片段分别插入到第4行,可允许代码编译?()  A、只有s1B、只有s3C、只有s1和s3D、只有s1和s4

考题 现有:   3.import java.util.*;   4.class ForInTest {   5.static List list = new ArrayList();  6.public static void main (String [] args){   7.  8.list.add("a"); list.add("b"); list.add("c");   9.//insert code here      10.System.out.print(o);  } }   哪一行插入到第9行将导致输出“abc”?() A、 for(Object o : list)B、 for(Iterator o : list)C、 for(Object o : list.iterator())D、 for(Iterator o : list.iterator(); o.hasNext (); )

考题 import java.util.*;  public class LetterASort {  public static void main(String[] args) {  ArrayList strings = new ArrayList();  strings.add(‟aAaA”);  strings.add(”AaA”); strings.add(‟aAa”);  strings.add(”AAaa”);  Collections.sort(strings);  for (String s: strings) { System.out.print(s + “ “); }  }  }  What is the result?() A、 Compilation fails.B、 aAaA aAa AAaa AaAC、 AAaa AaA aAa aAaAD、 AaA AAaa aAaA aAaE、 aAa AaA aAaA AAaaF、 An exception is thrown at runtime.

考题 现有:  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"?() A、  for (Iterator o  :  list.iterator();  o.hasNext  ();  )B、  for (Iterator 0  :  list)C、  for (Object o  :  list.iterator())D、  for (Object o  :  list)

考题 现有:  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?()     A、只在第11行B、在第8行和第11行C、在第5行、第8行和第11行D、在第2行、第5行、第8行和第11行

考题 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?() A、 Compilation fails.B、 Cannot add ToppingsC、 The code runs with no output.D、 A NullPointerException is thrown in Line 4.

考题 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?() A、for(char o: list)B、for(Object o: getList())C、for(Object o: getList();)D、for(Object o: o.getList())

考题 现有:  import java.util.*;      class AddStuff2  {  public static void main(String  []  args)  {      TreeSett=new TreeSet();      if (t.add("one"))      if (t.add("two"))     if (t.add ("three"))  add("four");  for (String s  :  t)      System.out.print (s);     }      }      结果为:()     A、 oneB、 one three twoC、 one two threeD、 one two three fourE、 four one three twoF、编译失败

考题 现有:  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?()     A、 for(char o: list)B、 for (Object o:  o.getList())C、 for(Object o: getList();)D、 for(Object o: getList())E、 for(Object o: o.getList();)

考题 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?() A、 3,2,1,B、 1,2,3,C、 Compilation fails.D、 The code runs with no output.E、 An exception is thrown at runtime.

考题 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]? ()A、 Set set = new TreeSet();B、 Set set = new HashSet();C、 Set set = new SortedSet();D、 List set = new SortedList();E、 Set set = new LinkedHashSet();

考题 现有:  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行,哪三行允许代码编译?()    A、 Map c= new SortedMap();B、 HashMap c= new HashMap();C、 HashMap c= new Hashtalole();D、 SortedMap c= new TreeMap();E、 ArrayList c= new ArrayList();F、  MaD c = new LinkedHashMap();

考题 1. import java.util.*;  2. public class Test {  3. public static void main(String[] args) {  4. List strings = new ArrayList();  5. // insert code here  6. }  7. }  Which four, inserted at line 5, will allow compilation to succeed?()A、 String s = strings.get(0);B、 Iterator i1 = strings.iterator();C、 String[] array1 = strings.toArray();D、 Iterator i2 = strings.iterator();E、 String[] array2 = strings.toArray(new String[1]);F、 Iterator i3 = strings.iterator();

考题 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”?()  A、 for(Object o : list)B、 for(Iterator o : list)C、 for(Object o : list.iterator())D、 for(Iterator o : list.iterator(); o.hasNext (); )

考题 现有:   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”?() A、 for(Object o : list)B、 for(Iterator o : list)C、 for(Object o : list.iterator())D、 for(Iterator o : list.iterator(); o.hasNext (); )

考题 多选题1. import java.util.*;  2. public class Test {  3. public static void main(String[] args) {  4. List strings = new ArrayList();  5. // insert code here  6. }  7. }  Which four, inserted at line 5, will allow compilation to succeed?()AString s = strings.get(0);BIterator i1 = strings.iterator();CString[] array1 = strings.toArray();DIterator i2 = strings.iterator();EString[] array2 = strings.toArray(new String[1]);FIterator i3 = strings.iterator();

考题 单选题现有:  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?()A  for(char o: list)B  for (Object o:  o.getList())C  for(Object o: getList();)D  for(Object o: getList())E  for(Object o: o.getList();)

考题 单选题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?()A  3,2,1,B  1,2,3,C  Compilation fails.D  The code runs with no output.E  An exception is thrown at runtime.

考题 单选题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?()A  Compilation fails.B  Cannot add ToppingsC  The code runs with no output.D  A NullPointerException is thrown in Line 4.

考题 单选题现有:  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"?()A   for (Iterator o  :  list.iterator();  o.hasNext  ();  )B   for (Iterator 0  :  list)C   for (Object o  :  list.iterator())D   for (Object o  :  list)

考题 单选题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]? ()A  Set set = new TreeSet();B  Set set = new HashSet();C  Set set = new SortedSet();D  List set = new SortedList();E  Set set = new LinkedHashSet();

考题 单选题现有:   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”?()A  for(Object o : list)B  for(Iterator o : list)C  for(Object o : list.iterator())D  for(Iterator o : list.iterator(); o.hasNext (); )

考题 单选题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?()A for(char o: list)B for(Object o: getList())C for(Object o: getList();)D for(Object o: o.getList())

考题 单选题1. import java.util.*;  2. class SubGen {  3. public static void main(String [] args) {  4. //insert code here  5. }  6. }  class Alpha { }  class Beta extends Alpha { }  class Gamma extends Beta { }  和四段代码片段:  s1. ArrayList〈? extends Alpha〉 list1 = new ArrayList〈Gamma〉();  s2. ArrayList〈Alpha〉 list2 = new ArrayList〈? extends Alpha〉();  s3. ArrayList〈? extends Alpha〉 list3 = new ArrayList〈? extends Beta〉();  s4. ArrayList〈? extends Beta〉 list4 = new ArrayList〈Gamma〉(); ArrayList〈? extends Alpha〉 list5 = list4;  哪些片段分别插入到第4行,可允许代码编译?()A 只有s1B 只有s3C 只有s1和s3D 只有s1和s4

考题 单选题import java.util.*;  public class LetterASort {  public static void main(String[] args) {  ArrayList strings = new ArrayList();  strings.add(‟aAaA”);  strings.add(”AaA”); strings.add(‟aAa”);  strings.add(”AAaa”);  Collections.sort(strings);  for (String s: strings) { System.out.print(s + “ “); }  }  }  What is the result?()A  Compilation fails.B  aAaA aAa AAaa AaAC  AAaa AaA aAa aAaAD  AaA AAaa aAaA aAaE  aAa AaA aAaA AAaaF  An exception is thrown at runtime.

考题 单选题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”?()A  for(Object o : list)B  for(Iterator o : list)C  for(Object o : list.iterator())D  for(Iterator o : list.iterator(); o.hasNext (); )

考题 单选题现有:   3.import java.util.*;   4.class ForInTest {   5.static List list = new ArrayList();  6.public static void main (String [] args){   7.  8.list.add("a"); list.add("b"); list.add("c");   9.//insert code here      10.System.out.print(o);  } }   哪一行插入到第9行将导致输出“abc”?()A  for(Object o : list)B  for(Iterator o : list)C  for(Object o : list.iterator())D  for(Iterator o : list.iterator(); o.hasNext (); )

考题 单选题现有:  import java.util.*;      class AddStuff2  {  public static void main(String  []  args)  {      TreeSett=new TreeSet();      if (t.add("one"))      if (t.add("two"))     if (t.add ("three"))  add("four");  for (String s  :  t)      System.out.print (s);     }      }      结果为:()A  oneB  one three twoC  one two threeD  one two three fourE  four one three twoF 编译失败