-1

I try to Create a custom unchecked exception class called InvalidDateException. This exception class must include a constructor that takes a String as an argument. But I wonder is my code is custom unchecked exception or not.

class InvalidDateException extends RuntimeException
{
      //Parameterless Constructor
      public WordContainsException() {}  

      //Constructor that accepts a message
      public InvalidDateException(String message)
      {
         super(message);
      }
 }
2h2h2h
  • 31
  • 7

2 Answers2

4

Since your class extends Exception, it's a checked exception. If you want to create an unchecked exception, you should extend RuntimeException.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

Yes your Exception class is a unchecked exception class as you have already extend with RuntimeException.

Moni
  • 433
  • 3
  • 9