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

题目
单选题
现有:  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.p”相关问题
  • 第1题:

    现有:  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

    正确答案:A

  • 第2题:

    现有如下包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  class Test { Alpha a; Beta b; Gamma c; }  哪三个必须加入到类 Test 中,以使其通过编译?()

    • A、package y;
    • B、package com;
    • C、import com.x.*;
    • D、import com.x.y.*

    正确答案:B,C,D

  • 第3题:

    与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.* “ %>

    正确答案:A

  • 第4题:

    现有:  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、 one
    • B、 one three two
    • C、 one two three
    • D、 one two three four
    • E、 four one three two
    • F、编译失败

    正确答案:E

  • 第5题:

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

    正确答案:D

  • 第6题:

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

    正确答案:A

  • 第7题:

    单选题
    在单一文件中import、class和package的正确出现顺序是()
    A

    package,import,class

    B

    class,import,package

    C

    import,package,class

    D

    package,class,import


    正确答案: D
    解析: 暂无解析

  • 第8题:

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


    正确答案: E
    解析: 暂无解析

  • 第9题:

    单选题
    与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.* “ %>


    正确答案: A
    解析: 暂无解析

  • 第10题:

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


    正确答案: B,C
    解析: 暂无解析

  • 第11题:

    单选题
    当在JSP文件中要使用到Vector对象时,应在JSP文件中加入以下哪个语句?()
    A

    〈jsp:include file=”java.util.*” /〉

    B

    〈jsp:include page=”java.util.*” /〉

    C

    〈%@ page import=”java.util.*” %〉

    D

    〈%@ page include=”java.util.*” %〉


    正确答案: D
    解析: 暂无解析

  • 第12题:

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


    正确答案: B
    解析: 暂无解析

  • 第13题:

    Given a file GrizzlyBear.java:  1. package animals.mammals;  2.  3. public class GrizzlyBear extends Bear {  4. void hunt() {  5. Salmon s = findSalmon();  6. s.consume();  7. }  8. }  and another file, Salmon.java:  1. package animals.fish; 2.  3. public class Salmon extends Fish {  4. void consume() { /* do stuff */ }  5. }  Assume both classes are defined in the correct directories for theft packages, and that the Mammal class correctly defines the findSalmon() method. Which two changes allow this code to compile correctly?()

    • A、 add public to the start of line 4 in Salmon.java
    • B、 add public to the start of line 4 in GrizzlyBear.java
    • C、 add import animals.mammals.*; at line 2 in Salmon.java
    • D、 add import animals.fish.*; at line 2 in GrizzlyBear.java
    • E、 add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
    • F、 add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java

    正确答案:A,D

  • 第14题:

    在单一文件中import、class和package的正确出现顺序是()

    • A、package,import,class
    • B、class,import,package
    • C、import,package,class
    • D、package,class,import

    正确答案:A

  • 第15题:

    定义Java.Applet程序时,必须有的import语句是()。

    • A、import  java.awt.event;
    • B、import  java.util. * ;
    • C、import  java.applet.Applet;
    • D、import  java.1ang.* ;

    正确答案:C

  • 第16题:

    现有:  import java.util.*;      class  ScanStuff  {  public  static void main (String  []  args)  {     String S= "x,yy,123";  Scanner sc = new Scanner (s);      while  (sc.hasNext())  System.out.print (sc.next()  +" ");     }      }  结果是什么?()     

    • A、  x yy
    • B、 x,yy,123
    • C、  x yy 123
    • D、  x,yy
    • E、编译失败
    • F、运行的时候有异常抛出

    正确答案:B

  • 第17题:

    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;

    正确答案:F

  • 第18题:

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

    正确答案:A,B,D

  • 第19题:

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


    正确答案: A,C
    解析: 暂无解析

  • 第20题:

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


    正确答案: F
    解析: 暂无解析

  • 第21题:

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


    正确答案: D
    解析: 暂无解析

  • 第22题:

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

    s1

    B

    s2

    C

    s2 和 s3

    D

    s2 和 s4


    正确答案: D
    解析: 暂无解析

  • 第23题:

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

     one

    B

     one three two

    C

     one two three

    D

     one two three four

    E

     four one three two

    F

    编译失败


    正确答案: D
    解析: 暂无解析

  • 第24题:

    单选题
    现有:  import java.util.*;      class  ScanStuff  {  public  static void main (String  []  args)  {     String S= "x,yy,123";  Scanner sc = new Scanner (s);      while  (sc.hasNext())  System.out.print (sc.next()  +" ");     }      }  结果是什么?()
    A

      x yy

    B

     x,yy,123

    C

      x yy 123

    D

      x,yy

    E

    编译失败

    F

    运行的时候有异常抛出


    正确答案: D
    解析: 暂无解析