Reputation: 177
Whether the Customized Exception is Checked or Unchecked Exception? How?
Upvotes: 1
Views: 181
Reputation: 392
depends on inheritance. if it inherits from RuntimeException it is unchecked. Otherwise it is checked
Upvotes: 0
Reputation: 11173
It depends on what it inherits. If your custom exception is a subclass of RuntimeException
then it is unchecked exception.
And if your custom exception extends Exception
class then it is checked exception.
See the Differences between Runtime/Checked/Unchecked/Error/Exception for more details
Upvotes: 0
Reputation: 4533
If you do like this:
public class CustomException extends Exception
then your CustomException is checked exception
If you do like this:
public class CustomException extends RuntimeException
then your CustomException is unchecked exception
Upvotes: 2
Reputation: 59203
If an exception inherits from RuntimeException
then it is unchecked. Otherwise it is checked.
Upvotes: 0