niusouti.com

11. public void addStrings(List list) {  12. list.add(”foo”);  13. list.add(”bar”);  14. }  What must you change in this method to compile without warnings?() A、 add this code after line 11: list = (List) list;B、 change lines 12 and 13 to: list.add(”foo”

题目

11. public void addStrings(List list) {  12. list.add(”foo”);  13. list.add(”bar”);  14. }  What must you change in this method to compile without warnings?() 

  • A、 add this code after line 11: list = (List) list;
  • B、 change lines 12 and 13 to: list.add(”foo”); list.add(”bar”);
  • C、 change the method signature on line 11 to: public void addStrings(List< extends String> list) {
  • D、 change the method signature on line 11 to: public void addStrings(List< super String> list) {
  • E、 No changes are necessary. This method compiles without warnings.

相似考题
更多“11. public void ”相关问题
  • 第1题:

    下列程序片段中,能通过编译的是( )。 A.public abstract class Animal{ public void speak;}S

    下列程序片段中,能通过编译的是( )。

    A.public abstract class Animal{ public void speak;}

    B.public abstract class Animal{ public void speak{);}

    C.public class Animal{ pubilc abstract void speak;}

    D.public abstract class Animal{ pubile abstract void speak{};}


    正确答案:A
    A。【解析】Java中一个类是一个abstract类的子类,它必须具体实现父类的abstract方法。如果一个类中含有abstract方法,那么这个类必须用abstract来修饰(abstract类也可以没有abstract方法)。有abstract方法的父类只声明,由继承它的子类实现。所以选A。

  • 第2题:

    如果获取XML文档中某一行的数据,需调用()方法。

    • A、public void setDocumentLocator()
    • B、public void unparsedEntityDecl()
    • C、public void fatalError()
    • D、public void startDocument()

    正确答案:A

  • 第3题:

    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?() 

    • A、 public class Employee extends Info implements Data { public void load() { /*do something*/ } }
    • B、 public class Employee implements Info extends Data { public void load() { /*do something*/ } }
    • C、 public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
    • D、 public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
    • E、 public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
    • F、 public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }

    正确答案:A

  • 第4题:

    当解析器解析到文档中一条指令时,会调用()方法。

    • A、public void processingInstruction()
    • B、public void skippedEntity()
    • C、public void unparsedEntityDecl()
    • D、public void startDocument()

    正确答案:A

  • 第5题:

    作为类中新线程的开始点,线程的执行是从()方法开始的。

    • A、public void start()
    • B、public void run()
    • C、public void int()
    • D、public static void main(Stringargs[])

    正确答案:A

  • 第6题:

    Which method must be defined by a class implementing the java.lang.Runnable interface? () 

    • A、 void run()
    • B、 public void run()
    • C、 public void start()
    • D、 void run(int priority)
    • E、 public void run(int priority)
    • F、 public void start(int priority)

    正确答案:B

  • 第7题:

    现有:  interface Data {public void load();}  abstract class Info {public abstract void load();}      下列类定义中正确使用Data和Info的是哪项?() 

    • A、 public class Employee implements Info extends Data { public void load(){/*dosomething*/}     }
    • B、public class Employee extends Inf.implements Data{ public void load() {/*do something*/}     }
    • C、public class Empl.yee implements Inf extends Data{ public void Data.1oad(){* do something*/}     public void load(){/*do something*/}     }
    • D、public class Employee extends Inf implements Data  {  public void Data.1oad()  {/*do something*/)     public void info.1oad(){/*do something*/}    }

    正确答案:B

  • 第8题:

    单选题
    Which method must be defined by a class implementing the java.lang.Runnable interface? ()
    A

     void run()

    B

     public void run()

    C

     public void start()

    D

     void run(int priority)

    E

     public void run(int priority)

    F

     public void start(int priority)


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

  • 第9题:

    单选题
    1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()
    A

     Value is: 8

    B

     Compilation fails.

    C

     Value is: 12

    D

     Value is: -12

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第10题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() {public void run() { doStuff(); }};

    B

    new Thread() {public void start() { doStuff(); }};

    C

    new Thread() {public void start() { doStuff(); }}.run();

    D

    new Thread() {public void run() { doStuff(); }}.start();

    E

    new Thread(new Runnable() {public void run() { doStuff(); }}).start();


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

  • 第11题:

    单选题
    10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?()
    A

     StackOverflowError

    B

     NullPointerException

    C

     NumberFormatException

    D

     IllegalArgumentException

    E

     ExceptionlnlnitializerError


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

  • 第12题:

    单选题
    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()
    A

     Line 13

    B

     Line 14

    C

     Line 18

    D

     Line 20


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

  • 第13题:

    10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?() 

    • A、 StackOverflowError
    • B、 NullPointerException
    • C、 NumberFormatException
    • D、 IllegalArgumentException
    • E、 ExceptionlnlnitializerError

    正确答案:A

  • 第14题:

    当解析器解析到文档中命名空间,会调用()方法。

    • A、public void startPrefixMapping()
    • B、public void startDocument()
    • C、public void setDocumentLocator()
    • D、public void characters()

    正确答案:A

  • 第15题:

    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

    • A、 public void setEnabled( boolean enabled) public boolean getEnabled()
    • B、 public void setEnabled( boolean enabled) public void isEnabled()
    • C、 public void setEnabled( boolean enabled) public boolean isEnabled()
    • D、 public boolean setEnabled( boolean enabled) public boolean getEnabled()

    正确答案:A,C

  • 第16题:

    下列方法中,与方法public void add(inta){}为合理重载的方法是()。

    • A、public int add(int a)
    • B、public void add(long a)
    • C、public void add(int a)
    • D、public void add(int a,int b)

    正确答案:D

  • 第17题:

    下面那一个函数是线程的入口函数? ()

    • A、private void run()
    • B、public void run()
    • C、public void start()
    • D、public void begin()

    正确答案:B

  • 第18题:

    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()  

    • A、 Line 13
    • B、 Line 14
    • C、 Line 18
    • D、 Line 20

    正确答案:D

  • 第19题:

    public class Test {} What is the prototype of the default constructor?()  

    • A、 Test()
    • B、 Test(void)
    • C、 public Test()
    • D、 public Test(void)
    • E、 public void Test()

    正确答案:C

  • 第20题:

    单选题
    interface Data { public void load(); }  abstract class Info { public abstract void load(); }  Which class correctly uses the Data interface and Info class?()
    A

     public class Employee extends Info implements Data { public void load() { /*do something*/ } }

    B

     public class Employee implements Info extends Data { public void load() { /*do something*/ } }

    C

     public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }

    D

     public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }

    E

     public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }

    F

     public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }


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

  • 第21题:

    多选题
    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    public void setEnabled( boolean enabled) public boolean getEnabled()

    B

    public void setEnabled( boolean enabled) public void isEnabled()

    C

    public void setEnabled( boolean enabled) public boolean isEnabled()

    D

    public boolean setEnabled( boolean enabled) public boolean getEnabled()


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

  • 第22题:

    单选题
    1. interface A { public void aMethod(); }  2. interface B { public void bMethod(); }  3. interface C extends A,B { public void cMethod(); }  4. class D implements B {  5. public void bMethod() { }  6. }  7. class E extends D implements C {  8. public void aMethod() { }  9. public void bMethod() { }  10. public void cMethod() { }  11. }  What is the result?()
    A

     Compilation fails because of an error in line 3.

    B

     Compilation fails because of an error in line 7.

    C

     Compilation fails because of an error in line 9.

    D

     If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.

    E

     If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.

    F

     If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.


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

  • 第23题:

    多选题
    Which two code fragments will execute the method doStuff() in a separate thread?()
    A

    new Thread() { public void run() { doStuff(); } }

    B

    new Thread() { public void start() { doStuff(); } }

    C

    new Thread() { public void start() { doStuff(); } } .run();

    D

    new Thread() { public void run() { doStuff(); } } .start();

    E

    new Thread(new Runnable() { public void run() { doStuff(); } } ).run();

    F

    new Thread(new Runnable() { public void run() { doStuff(); } }).start();


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

  • 第24题:

    单选题
    public class Test {} What is the prototype of the default constructor?()
    A

     Test()

    B

     Test(void)

    C

     public Test()

    D

     public Test(void)

    E

     public void Test()


    正确答案: D
    解析: The correct answer to this question is C. The default constructor always takes the same access of the class. In this case, the class is public and so does the default constructor.