Hello everybody. On Tuesday I had my exam on Java at the University. While I passed the exam (:D) there is one question to which I didn't answer correctly. There was this snippet of code:
class MyExc1 extends Exception {}
class MyExc2 extends Exception {}
class MyExc3 extends MyExc2 {}
public class C1 {
public static void main(String [] argv) throws Exception {
try {
System.out.print(1);
q();
}
catch ( Exception i ) {
throw( new MyExc2() );
}
finally {
System.out.print(2);
throw( new MyExc1() );
}
}
static void q() throws Exception {
try {
throw( new MyExc1() );
}
catch( Exception y ) {
}
finally {
System.out.print(3);
throw( new Exception() );
}
}
}
and I was asked to give its output. I answered "13Exception in thread main MyExc2", but the correct answer is "132Exception in thread main MyExc1". Why is it that? I just can't understand where does MyExc2 go :S Thanks to all