Exceptions Flashcards
Checked vs. unchecked exceptions. Why would one use former or later?
Checked - need to handle
Unchecked - no need
Difference in Error and UncheckedException
error - should not try to catch
exchecption - might want to catch
Could we have only try and finally without catch
yes
Cases when the finally block isn’t executed
system exit 0
exception in finally
How to avoid catch block?
either catch or finally must follow try block
What is Suppressed exception?
suppression happens (automatically) only to exceptions that are thrown in a try-with-resources
the suppressed exception is recorded in the original exception
What is try-with-resources ?
ensures that each resource is closed at the end of the statement execution