| |
GeekInterview.com > Interview Questions > J2EE > Core Java
| Print | |
Question: Exception Handling
Answer: What is the output of the following program, When tested under JDK 5.0
class ExceptionDemo { public static void main(String[] args) { int a[] = new int[] {1,2,3,4,5}; try{ System.out.prinltln(a[6]); } catch(Exception e) { System.out.println("Catching Exception ..."); } catch(ArrayIndexOutofBoundsException ae) { System.out.println("Catching ArrayIndexOutOfBounds Exception ..."); } } }
|
| June 06, 2008 07:02:04 |
#6 |
| ramesh124 |
Member Since: June 2008 Total Comments: 2 |
RE: Exception Handling |
It will not compile The ERror because of the catching exceptions should start from child Class of Exceptions and from there it can go to parent class. If the catch blocks hierarchy is changed, it will compile successfully. |
| |
Back To Question | |