hi try { tryThis(); return; } catch (IOException x1) { System.out.println("exception 1"); return; } catch (Exception x2) { System.out.println("exception 2"); return; } finally { System.out.println("finally"); } What will appear in the standard output if tryThis() throws a NumberFormatException? Select the one right answer. a.Nothing b."exception 1", followed by "finally" c."exception 2", followed by "finally" d."exception 1" e."exception 2" can anybody explain how the ans is c since the NumberFormat Exception is not specified in any of the catch blocks. thanx sheri
An Exception can be caught in a catch statement that is of the same type as the execption throw or is a super class of the excpetion thrown. The full tree for this is
Since Exception is a super class of NumberFormatException it gets caught in the catch (Exception x2). Hope this helps