Difference between Unchecked exception or runtime exception

后端 未结 8 1531
忘了有多久
忘了有多久 2020-11-29 21:55

This was an interview question. What is the main difference between unchecked exception and error as both are not caught? They will terminate the program.

8条回答
  •  独厮守ぢ
    2020-11-29 22:15

    RuntimeExceptions and Errors like OutOfMemoryError don't need to be catched and can be thrown until they reach main() which will terminate the application.

    Other Exceptions cause an compile error if they are not catched or included in the throws list.

提交回复
热议问题