The correct answer is: C. either (a) or (b)
A catch block has a usable match if the type of the catch argument is a parent class of the thrown class or a child class of the thrown class.
For example, if a MyException
object is thrown, then a catch (MyException e)
block will match. A catch (Exception e)
block will also match, because Exception
is a parent class of MyException
.
However, a catch (Object e)
block will not match, because Object
is not a parent class of MyException
.