niusouti.com

( 26 )阅读下列程序片段Public void test(){Try{sayHello();system.out.println( “ hello ” );} catch (ArrayIndexOutOfBoundException e) {System.out.println( “ ArrayIndexOutOfBoundException ” );}catch(Exception e){System.out.println( “ Exception ” );}finally {System.out

题目

( 26 )阅读下列程序片段

Public void test(){

Try{

sayHello();

system.out.println( “ hello ” );

} catch (ArrayIndexOutOfBoundException e) {

System.out.println( “ ArrayIndexOutOfBoundException ” );

}catch(Exception e){

System.out.println( “ Exception ” );

}finally {

System.out.println( “ finally ” );

}

}

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

A) Hello

B) ArrayIndexOutOfBondsException

C) Exception

Finally

D) Hello

Finally


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

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

    A.Hello

    B.ArrayIndexOutOfBondsException

    C.ExceptionFinally

    D.HelloFinally


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

  • 第2题:

    下面的程序执行后,文件test中的内容是 void fun(char *fname, char *st) { FILE *myf; int i; myf=fopen (fname, "w"); for(i=0; i<strlen(st); i++) fputc(st[i], myf); fclose(myf); } int main(void){ fun("test", "new world"); fun("test", "hello,"); return 0; }

    A.new worldhello,

    B.hello,

    C.new world

    D.hello,rld


    A

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

    阅读下列程序片段 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。

  • 第5题:

    下面的程序执行后,文件test.t中的内容是 ()。 #include <stdio.h> void fun(char *fname,char *st) {FILE *myf;int i; myf=fopen(fname,"w"); for(i=0;i<strlen(st);i++) fputc(st[i],myf); fclose(myf); } int main(void) { fun("test.t","new world"); fun("test.t","hello,"); return 0; }

    A.hello,

    B.new worldhello,

    C.new world

    D.hello,rld


    hello,