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

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


相似考题
参考答案和解析
正确答案: F,B
解析: 暂无解析
更多“现有:  1. import java.util.*;      2.  3. Class FindStuff  { ”相关问题
  • 第1题:

    1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

    • A、 Compilation will succeed for all classes and interfaces.
    • B、 Compilation of class C will fail because of an error in line 2.
    • C、 Compilation of class C will fail because of an error in line 6.
    • D、 Compilation of class AImpl will fail because of an error in line 2.

    正确答案:C

  • 第2题:

    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

  • 第3题:

    写出分属于下列科的校园植物。 李亚科1.()2.()3.() 苹果亚科1.()2.()3.() 绣线菊亚科1.()2.() 蔷薇亚科() 十字花科1.()2.() 藜科1.()2.() 蓼科() 堇菜科() 卫矛科() 蝶形花科1.()2.()3.()


    正确答案:杏;李;桃;苹果;梨;山楂;珍珠梅;风箱果;玫瑰;独行菜;荠菜;猪毛菜;藜;巴天酸模;早开堇菜;桃叶卫矛;刺槐;紫花苜蓿;披针叶黄华

  • 第4题:

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

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

    正确答案:C

  • 第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题:

    多选题
    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
    解析: 暂无解析

  • 第8题:

    多选题
    现有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”? ()
    A

    doX();

    B

    X.doX();

    C

    x.X.doX();

    D

    x.X myX = new x.X(); myX.doX();


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

  • 第9题:

    单选题
    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
    解析: 暂无解析

  • 第10题:

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

    只有s1

    B

    只有s3

    C

    只有s1和s3

    D

    只有s1和s4


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

  • 第11题:

    单选题
    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()
    A

     Line 33 must be called within a try block.

    B

     The exception thrown by method1 in class a is not required to be caught.

    C

     The method declared on line 31 must be declared to throw a RuntimeException.

    D

     On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.


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

  • 第12题:

    单选题
    现有:  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
    解析: 暂无解析

  • 第13题:

    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

    • A、 Line 33 must be called within a try block.
    • B、 The exception thrown by method1 in class a is not required to be caught.
    • C、 The method declared on line 31 must be declared to throw a RuntimeException.
    • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

    正确答案:B

  • 第14题:

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

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

    正确答案:A

  • 第15题:

    与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

  • 第16题:

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

  • 第17题:

    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.

    正确答案:A

  • 第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题:

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


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

  • 第20题:

    单选题
    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
    解析: 暂无解析

  • 第21题:

    单选题
    与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
    解析: 暂无解析

  • 第22题:

    单选题
    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
    解析: 暂无解析

  • 第23题:

    多选题
    现有:  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
    解析: 暂无解析

  • 第24题:

    单选题
    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
    解析: 暂无解析