Catch Block

This lesson shows how multiple exceptions can be caught using the try-catch clause.

We'll cover the following...

Question # 1

If a block of code throws more than one type of exception, how can it be handled?

Multiple types of exceptions thrown by a snippet of code can be handled by multiple catch clauses followed by the try block. An example snippet appears below:

    void process(int val) {

        try {
            if (val == 1)
                // checked exception
                throw new
...