Exceptions Flashcards
What is an exception?
An abnormal or erroneous situation at runtime.
These situations throw an exception. Can be thrown by JVM or by the program itself.
Explain how the try-catch works.
The program tries the stuff in the try block.
If something fucks up and an exception is thrown, the program goes to the first line of whatever catch block is setup to handle the exception thrown.
If the current try-catch block can’t catch and handle the exception, the exception is thrown back to whatever method is called it.
This process repeats until finally the exception is caught and handled, OR the program terminates with an error (propagated out of the main method).
Describe the difference between runtime errors and exceptions?
Errors are unrecoverable situations, so the program must be terminated (eg. running out of memory).
Describe the difference between checked and unchecked exceptions.
Checked exceptions are checked by the compiler, while unchecked exceptions are not.