Multiple Choice Question

Quiz Guidelines



What will be the output when the following program is run?

package exceptions; 
public class TestClass{    
public static void main(String[] args) {        
hello();        }        
catch(MyException me){            
System.out.println(me);        }    }        
static void hello() throws MyException{        
int[] dear = new int[7];        
dear[0] = 747;        
foo();    }        
static void foo() throws MyException{        
throw new MyException("Exception from foo");    } } 
class MyException extends Exception {    
public MyException(String msg){        
super(msg);    }

(Assume that line numbers printed in the messages given below are correct)

Select 1 option 

A. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at exceptions.TestClass.doTest(    
at exceptions.TestClass.main( 
B. Error in thread "main" java.lang.ArrayIndexOutOfBoundsException 
C. exceptions.MyException: Exception from foo 
D. exceptions.MyException: Exception from foo    
at exceptions.TestClass.hello(    
at exceptions.TestClass.main( 

Q&A Set: