单选题public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()A  FinallyB  Compilation fails.C  The code runs with no output.D  An exception is thrown at runti

题目
单选题
public class Foo {  public static void main(String[] args) {  try {  return;  } finally {  System.out.println( “Finally” );  }  }  }  What is the result?()
A

 Finally

B

 Compilation fails.

C

 The code runs with no output.

D

 An exception is thrown at runtime.

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

public class foo {   public static void main (stringargs)   try {return;}   finally {system.out.printIn(“Finally”);}   }     What is the result?()  

  • A、 The program runs and prints nothing.
  • B、 The program runs and prints “Finally”
  • C、 The code compiles, but an exception is thrown at runtime.
  • D、 The code will not compile because the catch block is missing.

正确答案:B

第2题:

public class foo {  public static void main (string[]args)  try {return;}  finally {system.out.printIn(“Finally”);}  }  What is the result?()

  • A、 The program runs and prints nothing.
  • B、 The program runs and prints “Finally”
  • C、 The code compiles, but an exception is thrown at runtime.
  • D、 The code will not compile because the catch block is missing.

正确答案:B

第3题:

public static void parse(String str) {  try {  float f= Float.parseFloat(str);  } catch (NumberFormatException nfe) {  f= 0;  } finally {  System.out.println(f);  }  }  public static void main(String[] args) {  parse(”invalid”);  }  What is the result?() 

  • A、 0.0
  • B、 Compilation fails.
  • C、 A ParseException is thrown by the parse method at runtime.
  • D、 A NumberFormatException is thrown by the parse method at runtime.

正确答案:B

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

static void test() {  try {  String x=null;  System.out.print(x.toString() +“ “);  }  finally { System.out.print(“finally “); }  }  public static void main(String[] args) {  try { test(); }  catch (Exception ex) { System.out.print(”exception “); }  }  What is the result?() 

  • A、 null
  • B、 finally
  • C、 null finally
  • D、 Compilation fails.
  • E、 finally exception

正确答案:E

第6题:

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

第7题:

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

第8题:

1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  

  • A、 Class A
  • B、 Compilation fails.
  • C、 An exception is thrown at line 2.
  • D、 An exception is thrown at line 6.
  • E、 The code executes with no output.

正确答案:E

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

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

更多相关问题