OCA Java SE 8 Exception - OCA Mock Question Exception 17


Which of the following can be inserted in the blank to make the code compile?

     public static void main(String[] args) { 
        try { 
        } catch ( ___  e) { 
        } catch (RuntimeException e) { 
  1. Exception
  2. IOException
  3. IllegalArgumentException
  4. RuntimeException
  5. StackOverflowError
  6. None of the above.


C, E.


C is allowed because it is a more specific type than RuntimeException.

E is allowed because it isn't in the same inheritance tree as RuntimeException.

B is wrong since the method called inside the try block doesn't declare an IOException to be thrown.

D is wrong since the same exception can't be specified in two different catch blocks.

A is wrong since it's more general than RuntimeException and would make that block unreachable.