Java OCA OCP Practice Question 1045

Question

Which of the following pairs fill in the blanks to make this code compile?

Choose all that apply

7: public void r() _____ Exception { 
8:   ____ Exception(); 
9: } 
  • A. On line 7, fill in throw
  • B. On line 7, fill in throws
  • C. On line 8, fill in throw
  • D. On line 8, fill in throw new
  • E. On line 8, fill in throws
  • F. On line 8, fill in throws new


B, D.

Note

In a method declaration, the keyword throws is used.

To actually throw an exception, the keyword throw is used and a new exception is created.




PreviousNext

Related