-5

I am aware of run-time unchecked exceptions, but not checked exceptions. According to a video I found, checked and unchecked exceptions only happen at run time. I also discovered a page that claims checked exceptions happen during compilation. I used the Java 8 documentation, but I was unable to determine whether the checked exception happens at compile time or at run time. If you read anything in the Java documentation, do provide me with a reference.

If you read anything in the Java documentation, do provide me with a reference.

  • 3
    Both exceptions happen at runtime, but the compiler won't let you throw a checked exception unless that exception will be caught by code somewhere else in your program. So the difference is that one type of exception will produce a syntax error during compilation where the other one won't. - more precisely, a checked exception has to be either be caught by a try/catch inside the same method as where the exception is being thrown, or the containing method has to declare that it can throw that exception. None of this is necessary for an unchecked exception. – CryptoFool Jan 11 '23 at 06:00
  • https://docs.oracle.com/javase/tutorial/essential/exceptions/index.html – kleopatra Jan 11 '23 at 06:01

1 Answers1

-2

Checked Exceptions are to be handled by us by throwing a exception, While unchecked exceptions are handled by the compiler. To get some clarity regarding exceptions .Go through this documentation once.