I think most of you who tried Dan's mock exam is familiar with this piece of code:
This program will fail because the "second catch clause attempts to catch an exception that is never thrown in the try block.".
Now consider the following code:
Notice that the
BException included in the catch phrase is not being thrown, and yet this code will compile properly.
Now correct me if I am wrong here:
I assume that this is allowed because of
polymorphism. aMethod() could be overridden and the new method could throw a subclass of the AException (which is allowed). In this case, the the "try" clause in the superclass could still catch that exception.
Which is something like this:
[ June 19, 2003: Message edited by: Alton Hernandez ]
[ June 19, 2003: Message edited by: Alton Hernandez ]