| Author |
try-catch-final and throw new Exception cert question
|
Otto Deckelman
Ranch Hand
Joined: Mar 28, 2001
Posts: 30
|
|
This is a question in my Java cert study guide book. I do not understand what statement will catch the 'E1' exception. What lines of output are displayed by the following program? class Question { public static void main(String[] args) { for(int i=0;i<10;++i) { try { try { if(i % 3 == 0) throw new Exception("E0"); System.out.println(i); }catch (Exception inner) { i *= 2; if(i % 3 == 0) throw new Exception("E1"); }finally{ ++1; } }catch (Exception outer) { i += 3; }finally{ --1; } } } }
|
 |
Brian Lugo
Ranch Hand
Joined: Nov 10, 2000
Posts: 165
|
|
This statement will catch E1 exception: }catch (Exception outer) { Its a nested try-catch-finally block. E1 is thrown from the inner block and will be caught by the outer try block. Brian
|
 |
 |
|
|
subject: try-catch-final and throw new Exception cert question
|
|
|