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

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

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

第1题:

class A {   public String toString () {   return “4”;   }   }   class B extends A {   8. public String toString () {   return super.toString() + “3”;   }   }   public class Test {   public static void main(Stringargs) {   System.out.printIn(new B());   }   }   What is the result?()  

  • A、 Compilation succeeds and 4 is printed.
  • B、 Compilation succeeds and 43 is printed.
  • C、 An error on line 9 causes compilation to fail.
  • D、 An error on line 14 causes compilation to fail.
  • E、 Compilation succeeds but an exception is thrown at line 9.

正确答案:B

第2题:

class A {  public A() {  System.out.println(“hello from a”);  }  }  class B extends A {  public B () {  System.out.println(“hello from b”);  super();  }  }  public class Test {  public static void main(String args[]) {  A a = new B();  }  }   What is the result when main is executed?()  

  • A、 Compilation fails.
  • B、 hello from a
  • C、 hello from b
  • D、 hello from b hello from a
  • E、 hello from a hello from b

正确答案:A

第3题:

class A

{public int getNumber(int a){return a+1;}}

class B extends A

{public int getNumber(int a, char c){return a+2;}public static void main(String[] args){B b=new B();System.out.println(b.getNumber(0));}}

what is the result?()

A.compilation succeeds and 1 is printed

B.compilation succeeds and 2 is printed

C.compilation succeeds and 3 is printed

D.An error at this program cause compilation to fail


参考答案:A

第4题:

public class Test {  public static void main( String[] args) {  String foo = args[1];  String bar = args[2];  String baz = args[3];  System.out.println(“baz = “ + baz); }  }   And the command line invocation: java Test red green blue   What is the result?()  

  • A、 baz =
  • B、 baz = null
  • C、 baz = blue
  • D、 Compilation fails.
  • E、 An exception is thrown at runtime.

正确答案:E

第5题:

public class Test {  public static void main(String[] args) {  String str = NULL;  System.out.println(str);  }  }   What is the result?()  

  • A、 NULL
  • B、 Compilation fails.
  • C、 The code runs with no output.
  • D、 An exception is thrown at runtime.

正确答案:B

第6题:

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

第7题:

public class Alpha{  public static void main( string[] args ){  if ( args.length == 2 ) {  if ( args.[0].equalsIgnoreCase(“-b”) )  System.out.println( new Boolean( args[1] ));  }  }  }   And the code is invoked by using the command: java Alpha –b TRUE   What is the result?()  

  • A、 true
  • B、 null
  • C、 false
  • D、 Compilation fails.
  • E、 The code runs with no output.
  • F、 An exception is thrown at runtime.

正确答案:A

第8题:

publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?()

A.Compilationfails.

B.Compilationsucceedswitherrors.

C.Compilationsucceedswithwarnings.

D.Compilationsucceedswithoutwarningsorerrors.


参考答案:C

第9题:

public class Test {  public static void aMethod() throws Exception {  try {  throw new Exception(); } finally {  System.out.println(“finally”);  }  }  public static void main(String args[]) {  try {  aMethod();  } catch (Exception e) {  System.out.println(“exception”);  }  System.out.println(“finished”);  }  }  What is the result?()  

  • A、 finally
  • B、 exception finished
  • C、 finally exception finished
  • D、 Compilation fails.

正确答案:C

第10题:

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

更多相关问题