11. public class Test {  12. public void foo() {  13. assert

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

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class Test {  public static void main(String [] args) {  boolean assert = true;  if(assert) {  System.out.println(”assert is true”);  }  }  } Given:  javac -source 1.3 Test.java  What is the result?() 

  • A、 Compilation fails.
  • B、 Compilation succeeds with errors.
  • C、 Compilation succeeds with warnings.
  • D、 Compilation succeeds without warnings or errors.

正确答案:C

第2题:

public class Test {   public static void main (String args) {  string foo = “blue”;  string bar = foo;   foo = “green”;   System.out.printIn(bar);   }   }   What is the result?()  

  • A、 An exception is thrown.
  • B、 The code will not compile.
  • C、 The program prints “null”
  • D、 The program prints “blue”
  • E、 The program prints “green”

正确答案:D

第3题:

下列关于Test类的定义中,正确的是______。

A) class Test implements Runnabte{

public void run(){}

public void someMethod(){}

B) class Test implements Rnuuable{

public void run();

}

C) class Test implements Rnuuable{

public void someMethod();

}

D) class Test implements Rnuuable{

public void someMethod();{}

}

A.

B.

C.

D.


正确答案:A

第4题:

public class Test{  public static void main( String[] argv ){  // insert statement here  }  }   Which statement, inserted at line 3, produces the following output?()  Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)  

  • A、 assert true;
  • B、 assert false;
  • C、 assert false : true;
  • D、 assert false == true;
  • E、 assert false: false;

正确答案:C

第5题:

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

第6题:

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.

正确答案:D

第7题:

class One {   public One foo() { return this; }  }  class Two extends One {  public One foo() { return this; }  }  class Three extends Two {   // insert method here  }  Which two methods, inserted individually, correctly complete the Three class?()

  • A、 public void foo() { }
  • B、 public int foo() { return 3; }
  • C、 public Two foo() { return this; }
  • D、 public One foo() { return this; }
  • E、 public Object foo() { return this; }

正确答案:C,D

第8题:

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

第9题:

public class Test {  public static void main(String args[]) {  class Foo {  public int i = 3; }  Object o = (Object)new Foo();   Foo foo = (Foo)o;  System.out.println(“i = “ + foo.i); }  }  What is the result?()  

  • A、 i = 3
  • B、 Compilation fails.
  • C、 A ClassCastException is thrown at line 6.
  • D、 A ClassCastException is thrown at line 7.

正确答案:A

第10题:

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

更多相关问题