CSC 216 Lecture Notes - Lecture 7: Code Reuse, Stack Trace, Duplicate Code

56 views8 pages
9 Sep 2016
School
Course
Professor

Document Summary

Exception: an object representing an error or unusual condition. Unchecked exceptions: exceptions that don"t have to be handled for the program to compile: example: you don"t have to check your oil every time you turn on a car. Checked exceptions: exceptions that do need to be handled for the program to compile: example: you need to have your keys before you can access your car. For any checked exceptions, you must also throw the exception yourself, or catch (handle) the exception. All exceptions extend from a common superclass, exception. You can catch a general exception to handle any subclass: try { System. out. println( file was not found. ): similarly, you can state that a method throws any exception, too. public static void foo() throws exception { } Exception has a sibling, error, which represents more serious java problems: they both are children of the superclass throwable. Public type name (params) throws type {

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents