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

题目内容 (请给出正确答案)

现有:  1.  import java.util.*;      2.  class AddStuff  {  3.public static void main (String  []  args)    {      4.TreeSet  s= new TreeSet();      5.    s.add( "one"):      6.    s.add( "two"):  7.    //insert code here      8.for (String s2:  sorted)      9.System.out.print (s2+" ");      10.    }     11.  }  和四个代码片段:  s1.sortedSet  sorted=s.tailSet(s.first());  s2.sortedSet  sorted=s.tailSet(s.first());  s3.sortedSet  sorted=  (SortedSet)s .tailSet(s.first());  s4.SortedSet  sorted=  (SortSet)s .tailSet(s.first()); 分别插入到第7行,哪项可以编译?()     

  • A、s2
  • B、sl
  • C、s2和s3
  • D、s2和s4
  • E、s2, s3和s4
  • F、sl. s2. s3和s4

参考答案

更多 “ 现有:  1.  import java.util.*;      2.  class AddStuff  {  3.public static void main (String  []  args)    {      4.TreeSet  s= new TreeSet();      5.    s.add( "one"):      6.    s.add( "two"):  7.    //insert code here      8.for (String s2:  sorted)      9.System.out.print (s2+" ");      10.    }     11.  }  和四个代码片段:  s1.sortedSet  sorted=s.tailSet(s.first());  s2.sortedSet  sorted=s.tailSet(s.first());  s3.sortedSet  sorted=  (SortedSet)s .tailSet(s.first());  s4.SortedSet  sorted=  (SortSet)s .tailSet(s.first()); 分别插入到第7行,哪项可以编译?()     A、s2B、slC、s2和s3D、s2和s4E、s2, s3和s4F、sl. s2. s3和s4” 相关考题
考题 下列Application程序中,指定as为字符串数组类型,先创建一个HashSet对象并赋值,然后在屏幕输出s,请将程序补充完整。import java.util.*;public class test17_1{public static void main(String[] args){__________s=new HashSet();s.add("Hello");s.add("World");s.add(new Character('我'));s.add(new Integer(23));s.add("Hello");__________as={"W","o","r","1","d"};s.add(as);s.add(null);s.add(new Integer(23));s.add(null);System.out.println(__________);

考题 1. import java.util.*;  2. class AddStuff {  3. public static void main(String [] args) {  4. TreeSet〈String〉 s = new TreeSet〈String〉();  5. s.add("one");  6. s.add("two");  7. // insert code here  8. for(String s2 : sorted)  9. System.out.print(s2 + " ");  10. }  11. }  和四个代码片段:  s1. SortedSet sorted = s.tailSet(s.first());  s2. SortedSet〈String〉 sorted = s.tailSet(s.first());  s3. SortedSet sorted = (SortedSet)s.tailSet(s.first());  s4. SortedSet sorted = (SortedSet〈String〉)s.tailSet(s.first());  分别插入到第7行,哪项可以编译?() A、s1B、s2C、s2 和 s3D、s2 和 s4

考题 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.

考题 现有:   1.  class HorseRadish {   2.    // insert code here   3.    protected HorseRadish(int x) {    4.      System.out.println("bok choy");  5.    }  6.  }   7.  class Wasabi extends HorseRadish {   8.    public static void main(String [] args) {   9.      Wasabi w = new Wasabi();  10.   }    11. }   分别插入到第 2 行,哪两项允许代码编译并产生"bok choy" 输出结果?() A、 // just a commentB、 protected HorseRadish() { }C、 protected HorseRadish() { this(42);}D、 protected  HorseRadish() { new HorseRadish (42);}

考题 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、编译失败

考题 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. 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();

考题 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.

考题 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);

考题 1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()  A、 InsideOnew ei= eo.new InsideOn();B、 Eo.InsideOne ei = eo.new InsideOne();C、 InsideOne ei = EnclosingOne.new InsideOne();D、 EnclosingOne.InsideOne ei = eo.new InsideOne();

考题 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;

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

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

考题 定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     A、import utils.*;B、 import utils.Rep.*;C、 import static utils.Rep.twice;D、 static import utils.Rep.twice;

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

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

考题 单选题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. class AddStuff {  3. public static void main(String [] args) {  4. TreeSet〈String〉 s = new TreeSet〈String〉();  5. s.add("one");  6. s.add("two");  7. // insert code here  8. for(String s2 : sorted)  9. System.out.print(s2 + " ");  10. }  11. }  和四个代码片段:  s1. SortedSet sorted = s.tailSet(s.first());  s2. SortedSet〈String〉 sorted = s.tailSet(s.first());  s3. SortedSet sorted = (SortedSet)s.tailSet(s.first());  s4. SortedSet sorted = (SortedSet〈String〉)s.tailSet(s.first());  分别插入到第7行,哪项可以编译?()A s1B s2C s2 和 s3D s2 和 s4

考题 单选题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 AddStuff  {  3.public static void main (String  []  args)    {      4.TreeSet  s= new TreeSet();      5.    s.add( "one"):      6.    s.add( "two"):  7.    //insert code here      8.for (String s2:  sorted)      9.System.out.print (s2+" ");      10.    }     11.  }  和四个代码片段:  s1.sortedSet  sorted=s.tailSet(s.first());  s2.sortedSet  sorted=s.tailSet(s.first());  s3.sortedSet  sorted=  (SortedSet)s .tailSet(s.first());  s4.SortedSet  sorted=  (SortSet)s .tailSet(s.first()); 分别插入到第7行,哪项可以编译?()A s2B slC s2和s3D s2和s4E s2, s3和s4F sl. s2. s3和s4

考题 单选题1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()A  InsideOnew ei= eo.new InsideOn();B  Eo.InsideOne ei = eo.new InsideOne();C  InsideOne ei = EnclosingOne.new InsideOne();D  EnclosingOne.InsideOne ei = eo.new InsideOne();

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

考题 单选题现有:  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 编译失败

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