单选题public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMetho

题目
单选题
public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()
A

 ABCD

B

 Compilation fails.

C

 C is printed before exiting with an error message.

D

 BC is printed before exiting with an error message.

E

 BCD is printed before exiting with an error message.

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

第1题:

class Number {  public static void main(String [] args) {  try {  System.out.print(Integer.parseInt("forty ")); } catch (RuntimeException r) {  System.out.print("runtime ");  } catch (NumberFormatException e) {  System.out.print("number ");  }  }  }  结果是什么?() 

  • A、forty
  • B、number
  • C、runtime
  • D、编译失败

正确答案:D

第2题:

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

第3题:

static void test() throws RuntimeException {  try {  System.out.print(”test “);  throw new RuntimeException();  }  catch (Exception ex) { System.out.print(”exception “); }  }  public static void main(String[] args) {  try { test(); }  catch (RuntimeException ex) { System.out.print(”runtime “); }  System.out.print(”end “);  }  What is the result?() 

  • A、 test end
  • B、 Compilation fails.
  • C、 test runtime end
  • D、 test exception end
  • E、 A Throwable is thrown by main at runtime.

正确答案:D

第4题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result? () 

  • A、 AB
  • B、 BC
  • C、 ABC
  • D、 BCD
  • E、 Compilation fails.

正确答案:D

第5题:

现有:  class Flow {  public static void main(String [] args)   try {  System. out .print ("before") ;   doRiskyThing ( )  ;   System.out.print ("after ") ;   } catch (Exception fe) {  System.out.print ("catch") ;   }  System. out .println ( " done") ;  }  public static void doRiskyThing() throws Exception{   // this code returns unless it throws an Exception           }}  可能会产生哪两项结果 ?()  

  • A、 before catch
  • B、 before after done
  • C、 before catch done
  • D、 before after catch

正确答案:B,C

第6题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (Exception ex) {  System.out.print(“C”);  }  finally {  System.out.print(“B”);  }  System.out.print(“D”);  }  public static void badMethod() {  throw new Error();  }  }  What is the result?()  

  • A、 ABCD
  • B、 Compilation fails.
  • C、 C is printed before exiting with an error message.
  • D、 BC is printed before exiting with an error message.
  • E、 BCD is printed before exiting with an error message.

正确答案:B

第7题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()  

  • A、 AC
  • B、 BD
  • C、 ACD
  • D、 ABCD
  • E、 Compilation fails.

正确答案:C

第8题:

public class TestApp{   public static void main(String[] args){   try{   int i = 0;   int j = 1 / i;   System.out.println(“1”);   } catch(Exception e){   System.out.print(“3”);   } finally{   System.out.print(“4”);   }   }   }   上述程序运行后的输出是哪项?() 

  • A、 4
  • B、 34
  • C、 43
  • D、 14

正确答案:B

第9题:

public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”);  }  catch (RuntimeException ex) {  System.out.print(“B”);  }  catch (Exception ex1) {  System.out.print(“C”);  }   finally {  System.out.print(“D”);  }  System.out.print(“E”);  }  public static void badMethod() {  throw new RuntimeException();  }  }  What is the result?()  

  • A、 BD
  • B、 BCD
  • C、 BDE
  • D、 BCDE
  • E、 ABCDE
  • F、 Compilation fails.

正确答案:C

第10题:

class Flow {  public static void main(String [] args) {  try {  System.out.print("before ");  doRiskyThing();  System.out.print("after ");  } catch (Exception fe) {  System.out.print("catch ");  }  System.out.println("done ");  }   public static void doRiskyThing() throws Exception {  // this code returns unless it throws an Exception  } }  可能会产生下面哪两项结果?() 

  • A、before
  • B、before catch
  • C、before after done
  • D、before catch done

正确答案:C,D

更多相关问题