You can download the source code for the examples in the book and the solutions to the following exercises from http://www.wrox.com.
Write a program that will generate exceptions of type NullPointerException, NegativeArraySizeException, and IndexOutOfBoundsException. Record the catching of each exception by displaying the message stored in the exception object and the stack trace record.
Add an exception class to the last example that will differentiate between the index-out-of-bounds error possibilities, rethrow an appropriate object of this exception class in divide(), and handle the exception in main().
Write a program that calls a method that throws an exception of type ArithmeticException at a random iteration in a for loop. Catch the exception in the method and pass the iteration count when the exception occurred to the calling method by using an object of an exception class you define.
Add a finally block to the method in the previous example to output the iteration count when the method exits.