Error
or RuntimeException
types are unchecked; all other exceptions are checked. Some examples of unchecked exceptions are dividing by zero (ArithmeticException
), or accessing an index that doesn't exist (IndexOutOfBoundsException
).throw
keyword to create exceptions with custom error messages as follows:try catch
block, as such:tryCatchFinally()
is run?trying
will be printed.catching
is printed next.finally
is printed last.catch
block. What would this code do?trying
is printed.
2. finally
is printed.
3. The program exits with a RuntimeException
.