Chapter Summary
An exception is an object of a class derived from the class Exception. Descendants of the class
Error
are not exceptions, but they behave like them.Exception handling allows you to design and code the normal case for your program separately from the code that handles exceptional situations.
Java provides predefined exception classes. You can also define your own exception classes.
Java has two kinds of exceptions: checked and unchecked (run-time). A method that throws a checked exception must either handle it or declare it in a
throws
clause within its heading. Checked exceptions must be caught eventually. Otherwise, program execution will terminate. Unchecked, or run-time, exceptions need not be caught or declared in athrows ...
Get Java: An Introduction to Problem Solving and Programming, 8th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.