3

In my web application created a User defined exception extends with Exception.Is it Checked or unchecked exception

public class InvalidDataException extends Exception{ public InvalidDataException() { super(); // TODO Auto-generated constructor stub } /** * @param arg0 */ public InvalidDataException(String message) { super(message); // TODO Auto-generated constructor stub } } 

5 Answers 5

9

Only those exceptions that are subclasses of RuntimeException are considered unchecked.

Yours isn't, and therefore is a checked exception.

Sign up to request clarification or add additional context in comments.

2 Comments

But defualtly runtime exception extends with Exception.Can i say Unchecked Exception
@user1357722: If you want an unchecked exception, extend RuntimeException. If you don't, don't. Simple as that.
1

It's a checked exception class. Any class which extends Exception class will be a user defined Checked exception class. Where as any class which extends RuntimeException will be Unchecked exception class.

Comments

0

You could have used IllegalArgumentException.

This exception is unchecked whereas yours is checked as @duffymo & @aix commented.

Comments

0

User Defined exceptions are checked exceptions because they are extended with Exception class which is super class for all the exceptions occured,where as unchecked exceptions are extended with run time Exceptions.

Comments

0

THere are two classes call as partially checked exception.

1.) Exception class

2.) throwable class

It calls partially checked because some of their subclasses are Unchecked. So you have extended the Exception class then it's Checked exception

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.