When did the checked exception occurs?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

When did the checked exception occurs??

I found a video says "The exception either it is checked or unchecked, it is generated at run time only ..." But also I found a website, says checked exception occurs at compile time...

29th Jan 2019, 11:02 AM
Mansi Parkale
2 Answers
+ 4
Actually, checked exceptions need to be handled by your code(either catched or thrown). If any checked exception is not handled by your code, it will not compile.
29th Jan 2019, 11:14 AM
Helio Oliveira Bianchi
Helio Oliveira Bianchi - avatar
+ 3
The exception itself does not occur at compile time. What happens is that a compilation error occurs if there is no code that handles the exception.
29th Jan 2019, 11:27 AM
Helio Oliveira Bianchi
Helio Oliveira Bianchi - avatar