154k views
4 votes
Which statements are correct about 'unchecked exceptions'?

a) Exceptions inherit from 'Exception'
b) Exceptions inherit from 'Error'
c) Exceptions inherit from 'RuntimeException' class
d) All of the above

User Daoud
by
7.6k points

1 Answer

6 votes

Final answer:

Unchecked exceptions in Java inherit from the 'RuntimeException' class, which means that option c) is the correct statement.

Step-by-step explanation:

In regards to the correct statements about 'unchecked exceptions' in Java:

  • Exceptions inherit from 'Exception': This is partially true. All exceptions in Java are subclasses of java.lang.Exception, but this is not specific enough for unchecked exceptions.
  • Exceptions inherit from 'Error': This is incorrect. Errors are a separate category under java.lang.Throwable. They represent serious problems that a reasonable application should not try to catch.
  • Exceptions inherit from 'RuntimeException' class: This is correct. Unchecked exceptions are those that extend java.lang.RuntimeException and do not need to be declared in a throws clause or surrounded in a try-catch block.

Therefore, the correct statement regarding 'unchecked exceptions' is c) Exceptions inherit from 'RuntimeException' class.

User Amitava Mozumder
by
7.8k points