niusouti.com

阅读下列程序片段。Public void test{Try{sayHello;system.out.println("hello"):}catch(ArraylndexOutOfBoundException e){System.out.println("ArraylndexOutOfBoundExcep—tion");}catch(Exception e){System.out.println("Exception"):}finally{System.Out.println("finally");}}如果

题目

阅读下列程序片段。

Public void test{

Try{

sayHello;

system.out.println("hello"):

}catch(ArraylndexOutOfBoundException e){

System.out.println("ArraylndexOutOfBoundExcep—

tion");

}catch(Exception e){

System.out.println("Exception"):

}finally{

System.Out.println("finally");

}

}

如果sayHello方法正常运行,则test方法的运行结果将是( )。

A.Hello

B.ArraylndexOutOfBondsException

C.ExceptionFinally

D.HelloFinally


相似考题
更多“阅读下列程序片段。Public void test{Try{sayHello;system.out.println("hello"):}catc ”相关问题
  • 第1题:

    如下的代码段中,如果方法unsafe()正常运行,那么结果是( )。 public void example() { try { unsafe(); System.out.println("Testl"); }catch(SafeException e) { System.out.println("Test 2"); }finally{ System.out.println("Test 3'); } System.out.println("Test 4"); }

    A.Test 3 Test 4

    B.Test1 Test3 Test4

    C.Test1 Test3

    D.Test1 Test4


    正确答案:B
    解析:在正常情况下,打印Test1、Test3、Test4:在产生可捕获异常时,打印Test2、Test3、Test4;在产生不可捕获异常时,打印Test3,然后终止程序。注意finally后面的语句总是被执行。

  • 第2题:

    阅读下列程序片段。如果sayHello( )方法正常运行,则test( )方法的运行结果将是( )。

    A.Hello

    B.ArrayIndexOutOfBondsException

    C.ExceptionFinally

    D.HelloFinally


    正确答案:D
    sayHello()方法正常运行则程序不抛出异常,并执行finally,所以为符合选项D。

  • 第3题:

    如果下列的方法能够正常运行,在控制台上将不显示()选项。 public void example() { try{ unsafe();     System.out.println("Test1"); }catch(SafeException e) { System.out.println("Test2"); }finally{ System.out.println("Test3"); } System.out.println("Test4"); }

    A.Test1

    B.Test2

    C.Test3

    D.Test4


    ACD

  • 第4题:

    阅读下列程序片段。 Public void test{ Try{ sayHello; system.out.println("hello"): }catch(ArraylndexOutOfBoundException e){ System.out.println("ArraylndexOutOfBoundExcep— tion"); }catch(Exception e){ System.out.println("Exception"): }finally{ System.Out.println("finally"); } } 如果sayHello方法正常运行,则test方法的运行结果将是( )。

    A.Hello

    B.ArraylndexOutOfBondsException

    C.Exception Finally

    D.Hello Finally


    正确答案:D
    D。【解析】sayHello方法正常运行则程序不抛出异常,并执行finally,所以为D。

  • 第5题:

    阅读下列程序片段 Publicvoidtest(){ Try{ sayHello(); system.out.println(“hello"); }catch(ArrayIndexOutOfBoundExceptione){ System.out.println(“ArraylndexOutOfBoundException”); }catch(Exceptione){ System.out.println(“Exception”); }finally{ System.out.println(“finally”); } } 如果sayHello()方法正常运行,则test()方法的运行结果将是( )。

    A.Hello

    B.ArraylndexOutOfBondsException

    C.Exception Finally

    D.Hello Finally


    正确答案:D
    解析:sayHello()方法正常运行则程序不抛出异常,并走finally,所以为D。