OCA Java SE 8 Exception - OCA Mock Question Exception 4








Question

Which of the following pairs fill in the blanks to make this code compile? (Choose all that apply)

     1: public void aMethod() _____ Exception { 
     2:   _____________ Exception(); 
     3: } 
  1. On line 1, fill in throw
  2. On line 1, fill in throws
  3. On line 2, fill in throw
  4. On line 2, fill in throw new
  5. On line 2, fill in throws
  6. On line 2, fill in throws new




Answer



B, D.

Note

In a method declaration, the keyword throws is used.

To throw an exception, use throw.