In order to have some code throw an exception, you would use which of the following reserved words?

In order to have some code throw an exception, you would use which of the following reserved words?

a)       throw
b)       throws
c)       try
d)       Throwable
e)       goto

Answer:  a.

Explanation:  The reserved word throw is used to throw an exception when the exception is detected, as in:  if (score < 0) throw new IllegalTestScoreException(“Input score ” + score + “ is negative”);


Enhancing Classes

Learn More Multiple Choice Question :