OCA Java SE 8 Exception - OCA Mock Question Exception 14


Which of the following can be inserted into Rectangle to make this code compile? (Choose all that apply)

     class ExceptionA extends Exception {} 
     class ExceptionB extends RuntimeException {} 
     interface Printable { 
         void output() throws ExceptionA; 
     class Rectangle implements Printable {
        // INSERT CODE HERE 
  1. public void output(){}
  2. public void output() throws Exception{}
  3. public void output() throws ExceptionA{}
  4. public void output() throws IllegalArgumentException{}
  5. public void output() throws ExceptionB{}


A, C, D, E.


output() can throw no exceptions so A correct.

output() cal also throw runtime exceptions so D and E correct.

C is correct since it matches the signature in the interface.