GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  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 23:40:54 #7
 manu.raj2007   Member Since: June 2008    Total Comments: 1 

RE: Exception Handling
 
This code results in a compilation error because ArrayIndexOutOfBoundsException has already been caught by its base class Exception.
     

 

Back To Question