• 2022-06-08
    下面程序的执行结果是( )。public class Test {public static void main(String[] args) {new Test().test();}public void test(){try{System.out.print("try");}catch(ArrayIndexOutOfBoundsException e){System.out.print("catch1");}catch(Exception e){System.out.print("catch2");}finally{System.out.println("finally");}}}
    A: try finally
    B: try catch1 finally
    C: try catch2 finally
    D: finally
  • A
    本题目来自[网课答案]本页地址:https://www.wkda.cn/ask/pymemottatxoejo.html

    举一反三

    内容

    • 0

      下面关于try、catch和finally语句块的组合使用,正确的是() A: try{,} B: try{,}finally{,} C: try{,}catch{,}finally{,} D: try{,}catch{,}catch{,}

    • 1

      请说出下列程序的输出结果_____________,_____________。import java.io.IOException;public class E {public static void main(String args[]){try { methodA();}catch(IOException e){System.out.print("你好");return;}finally {System.out.println("thanks");}}public static void methodA() throws IOException{throw new IOException();}}

    • 2

      阅读下面的代码段,屏幕的输出是什么?public static void main(String[] args) { try{tryThis();return;}catch(IOException x1){ System.out.println("exception 1");return;}catch(Exception x2){System.out.println("exception 2");return;}finally{ System.out.println("finally");} } static void tryThis() throws IOException{ throw new IOException(); } A: ”exception1”后面跟着”finally” B: ” exception2”后面跟着“finally” C: ”exception1” D: ”exception2”

    • 3

      使用捕获异常时,哪些组合使用方式是正确的 A: try{ }catch(){ } B: try{ }catch(){ }finally{ } C: try{ }finally{ } D: try{ }catch(){ }catch(){ }catch(){ }finally{ }

    • 4

      下列程序的输出结果是______。 public class Test public static void main(String[]args) int[]array=(2,4,6,8,10); int size=6; int result=-1; try for(int i=0;i<size&&result==-1;) if(array[i]==20)result=i; catch(ArithmeticException e)﹛ System.out.println("Catch———1"); catch(ArrayIndexOutOfBoundsException e) System.OUt.println("Catch———2"); catch(Exception e) System.out.println("Catch———3");[/i] A: Catch———1 B: Catch———2 C: Catch———3 D: 以上都不对