Chapter Summary
An exception is an object of a class derived from the class Exception. Descendants of the class
Errorare 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
throwsclause 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access