CS 121 Lecture 69: The try-catch Statement

27 views3 pages

Document Summary

The try-catch statement: identifies a block of statements that may throw an exception. A product code includes, among other info, a character in the. 10th position that represents the zone from which that product was made. & a 4-digit integer in positions 4 through 7 that represents the district in which it will be sold. Due to some recognition, products from zone r are banned from being sold in districts w/ a designation of 2000 or higher. A try statement contains a block of code followed by 1 or more catch clauses. If an exception occurs in the try block, the code of the corresponding catch cause is executed. The finally clause, if present, is executed no matter how the try block is exited. The finally clause: defines a section of code that is executed no matter how the try block is exited. A try-catch statement can have an optional finally clause.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents