User defined exception are checked or unchecked exceptions

前端 未结 5 2065
后悔当初
后悔当初 2021-01-21 07:52

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

public class InvalidDataException extends Exc         


        
相关标签:
5条回答
  • 2021-01-21 08:25

    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.

    0 讨论(0)
  • 2021-01-21 08:34

    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.

    0 讨论(0)
  • 2021-01-21 08:36

    You could have used IllegalArgumentException.

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

    0 讨论(0)
  • 2021-01-21 08:40

    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

    0 讨论(0)
  • 2021-01-21 08:43

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

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

    0 讨论(0)
提交回复
热议问题