Skip to content
Sharp

Exceptions · interview question

Which Java keyword is used to define a custom exception class?

Multiple choiceMediumchapter-6-curatedpremiumexceptionscustom-exceptions
Choose one answer
Answer and explanation

Correct answer

A. Extends

Why

The 'extends' keyword is used to define a custom exception class by extending either Exception or RuntimeException, depending on whether you want the exception to be checked or unchecked.

Test yourself on Exceptions

A free test with instant, explained results. No account needed.

Start free test
All Exceptions questions →