Checked and Unchecked Exceptions

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

The Java runtime system catches it.

Checked and Unchecked Exceptions

The Java runtime system will catch the exception, just as your code can do with a catch{} block, and then prints out the message and the stack trace of the exception.

Here is a list of some exception types, with the checked exceptions indicated. Only RunTimeException and its subclasses are not checked. The parent class, Exception is checked.

Exception CHECKED

    IOException CHECKED

    AWTException CHECKED

    RunTimeException
        ArithmeticException
        IllegalArgumentException
            NumberFormatException
        IndexOutOfBoundsException
        NoSuchElementException
            InputMismatchException   
        Others

    Others CHECKED

QUESTION 6:

(Review: ) What are two ways your code can handle a checked exception?