Chapter 10Exceptions
OCP EXAM OBJECTIVES COVERED IN THIS CHAPTER:
- Handling Exceptions
- Describe the advantages of Exception handling and differentiate among checked, unchecked exceptions, and Errors
- Create try-catch blocks and determine how exceptions alter program flow
- Create and invoke a method that throws an exception
Many things can go wrong in a program. Java uses exceptions to deal with some of these scenarios. This chapter focuses on how exceptions are created, how to handle them, and how to distinguish between various types of exceptions and errors.
Understanding Exceptions
A program can fail for just about any reason. Here are just a few possibilities:
- The code tries to connect to a website, but the Internet connection is down. ...
Get OCP Oracle Certified Professional Java SE 11 Developer Complete Study Guide 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.