CS1027b Computer Science Fundamentals II

Lab 4

General lab instructions to help labs run smoothly

Overview and preparation

We will work with exceptions and practice debugging For preparation, review the lecture notes on Java exceptions.

Don't forget to submit your work on owl.

Exercise 1: Experimenting with Exceptions

In this exercise, you will experiment with some examples of code that generates exceptions and answer some questions on the examples. Download the Exception Examples 1, 2, 6, 7, 8, 9, 10, 11, and 12 from the Sample Code section of the course webpage. It may be simplest if you put them all in one project, and run them separately as you progress through this Exercise. Note that some of them will (purposely) not compile.

Exercise 2

Eclipse comes with a debugger which allows you to single-step through your code one statement at a time, trace variables, stop the execution at any time, and find errors in this way. In this exercise you will use the debugger to trace through the program DebuggingExercise.java.