OCA Java SE 8 Exception - OCA Mock Question Exception 10








Question

Which of the following statements are true? (Choose all that apply)

  1. You can declare a method to return Exception type.
  2. You can declare subclass of Error to throw in throws part of a method declaration.
  3. You can declare subclass of Exception to throw in the throws part of a method declaration.
  4. You can declare subclass of Object to throw.
  5. You can declare subclass of RuntimeException in the throws part of a method declaration.




Answer



A, B, C, E.

Note

Classes listed in the throws part of a method declaration must extend java.lang.Throwable.

This includes Error, Exception, and RuntimeException.

Any Java type, including Exception, can be declared as the return type.