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 12:33:49 #9
 rinumca   Member Since: June 2008    Total Comments: 7 

RE: Exception Handling
 
Here the child exception is caught before parent. In your program there are two compilation errors they are println is typed wrong and ArrayIndexOutOfBoundsException is also typed worng which result in compilation errors
     

 

Back To Question