Computer Science 111:

Introduction to Computer Science I

Gregory M. Kapfhammer


wocintech stock - 34 flickr photo by wocintechchat.com shared under a Creative Commons ( BY ) license

Color Scheme

Key Concept

Corresponding Diagram

In-Class Discussion

In-Class Activity

Details in the Textbook

Exception Handling

In Chapter 11?

What could go wrong?

What could go wrong with software?

File system problems

Network problems

Program that divides a variable by zero

How to Handle?

Do not handle the exception

Handle the exception where it occurs

Handle the exception somewhere else in the program

What are the trade-offs of these solutions?

Uncaught exceptions

Caught Exceptions

Types of exceptions similar and different?

Try-Catch Statements

Finally Clauses

Turn to pages 542 and 543

Pull from your share repository

Compile and run the ProductCodes example

Run the program using the textbook's examples

Try a code that is not numeric

Try valid, invalid, and banned codes

The exceptions are handled with catch blocks!

The Exception Class Hierarchy

See Figure 11.1 on page 549

Compile and run CreatingExceptions

Try inputs that are and are not in range

What happens when you run this program?

Compile and run TestData

What is the output of TestData?

Change the second file name in TestData

What exception is thrown? Why?

Any questions about exceptions?