单选题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?()Afor(char o: list)Bfor(Object o: getList())Cfor(Object o: getList();)Dfor(Object o: o.getList())

单选题
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())


参考解析

解析: 暂无解析

相关考题:

现有:   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 Banana3 {  public static void main(String [] args) {  int x = 2;  Banana3 b = new Banana3();  b.go(x);  }  static { x += x; }  void go(int x) {  ++x;  System.out.println(x);  }  }  结果为:()  A、2B、3C、5D、编译失败

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;

1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  A、 Class AB、 Compilation fails.C、 An exception is thrown at line 2.D、 An exception is thrown at line 6.E、 The code executes with no output.

You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to anArrayList object. Which two JSP code snippets can you use to import these list types?()A、%! import java.util.*; %B、%! import java.util.List;import java.util.ArrayList; %C、%@ page import=’java.util.List’import=’java.util.ArrayList’ %D、%@ import types=’java.util.List’types=’java.util.ArrayList’ %E、%@ page import=’java.util.List,java.util.ArrayList’ %F、%@ import types=’java.util.List,java.util.ArrayList’ %

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

与page指令%@ page import= “java.util.*, java.text.* “ % 等价的是()。A、%@ import="“java.util.*" page=""%@ import="“java.text.*" page=""%@ import="“java.text.*" page=""%@ import="“java.util.*" page=""%@ import="“java.text.*" page=""%@ import="“java.util.*" page=""%@ page import= “java.util.* % %@ page import= “java.text.* “ % B、%@ page import= “java.util.*”  ,  import= “java.text.* “ % C、%@ page import= “java.util.* “  ;  % %@ page import= “java.text.* “  ; %D、%@ page import= “java.util.* ; java.text.* “ %

现有:  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();)

ClassOne.java: 1. package com.abe.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() { return var; } 5. } ClassTest.java: 1. package com.abe.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[] args) { 5. char a = new ClassOne().getVar();6. char b = new ClassTest().getVar(); 7. } 8. } What is the result?()A、 Compilation fails.B、 Compilation succeeds and no exceptions are thrown.C、 An exception is thrown at line 5 in ClassTest.java.D、 An exception is thrown at line 6 in ClassTest.java.

Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A、import utils.*;B、static import utils.*;C、importutils.Repetition.*;D、static importutils.Repetition.*;E、import utils.Repetition.twice();F、import static utils.Repetition.twice;G、static import utils.Repetition.twice;

1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()  A、 static class InnerOne { public double methoda() { return d1; } }B、 static class InnerOne { static double methoda() { return d1; } }C、 private class InnerOne { public double methoda() { return d1; } }D、 protected class InnerOne { static double methoda() { return d1; } }E、 public abstract class InnerOne { public abstract double methoda(); }

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 Hashtable();D、SortedMap c = new TreeMap();

多选题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();

单选题ClassOne.java  1. package com.abc.pkg1;  2. public class ClassOne {  3. private char var = ‘a’;   4. char getVar()  {return var;}  5. }  ClassTest.java    1. package com.abc.pkg2;  2. import com.abc.pkg1.ClassOne;  3. public class ClassTest extends ClassOne {  4.   public static void main(String[]args)  {  5.     char a = new ClassOne().getVar();  6.     char b = new ClassTest().getVar();   7.   }  8. }      What is the result?()A Compilation will fail.B Compilation succeeds and no exceptions are thrown.C Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.D Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.

多选题现有2 个文件:  1. package x;  2. public class X {  3. public static void doX() { System.out.print("doX "); }  4. }  和:  1. class Find {  2. public static void main(String [] args) {  3. //insert code here  4. }  5. }  哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()AdoX();BX.doX();Cx.X.doX();Dx.X myX = new x.X(); myX.doX();

单选题Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. public static void process(byte[]) { /* more code here */ }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()A process(bytes);B BitUtils.process(bytes);C util.BitUtils.process(bytes);D SomeApp cannot use methods in BitUtils.E import util.BitUtils.*; process(bytes);

单选题Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()A process(bytes);B BitUtils.process(bytes);C app.BitUtils.process(bytes);D util.BitUtils.process(bytes);E import util.BitUtils. *; process(bytes);F SomeApp cannot use the process method in BitUtils.

单选题现有:   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 (); )

单选题与page指令 等价的是()。A%@ import="“java.util.*" page=""%@ import="“java.text.*" page=""%@ import="“java.text.*" page=""%@ import="“java.util.*" page=""%@ import="“java.text.*" page=""%@ import="“java.util.*" page=""%@ page import= “java.util.* % %@ page import= “java.text.* “ % B%@ page import= “java.util.*”  ,  import= “java.text.* “ % C%@ page import= “java.util.* “  ;  % %@ page import= “java.text.* “  ; %D%@ page import= “java.util.* ; java.text.* “ %

单选题现有:   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 (); )

单选题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 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

多选题现有:  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行,哪三行允许代码编译?()AMap c= new SortedMap();BHashMap c= new HashMap();CHashMap c= new Hashtalole();DSortedMap c= new TreeMap();EArrayList c= new ArrayList();FMaD c = new LinkedHashMap();

多选题1. public class OuterClass {  2. private double d1 = 1.0;  3. // insert code here  4. }  Which two are valid if inserted at line 3?()Astatic class InnerOne { public double methoda() { return d1; } }Bstatic class InnerOne { static double methoda() { return d1; } }Cprivate class InnerOne { public double methoda() { return d1; } }Dprotected class InnerOne { static double methoda() { return d1; } }Epublic abstract class InnerOne { public abstract double methoda(); }

多选题You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to anArrayList object. Which two JSP code snippets can you use to import these list types?()A%! import java.util.*; %B%! import java.util.List;import java.util.ArrayList; %C%@ page import=’java.util.List’import=’java.util.ArrayList’ %D%@ import types=’java.util.List’types=’java.util.ArrayList’ %E%@ page import=’java.util.List,java.util.ArrayList’ %F%@ import types=’java.util.List,java.util.ArrayList’ %

单选题Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  3. public class Demo {  4. public static void main(String[] args) {  5. System.out.println(twice(”pizza”));  6. }  7. }  Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition. *;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;