Posts

Image
This chapter is taken from the book - Getting started with Java programming language ( https://www.amazon.com/dp/1544614519/ ). You can download the code for the book from here:  https://drive.google.com/file/d/0B1IwsLB5TOglZXYxWW9JMndUX3M/view Chapter 8 - Exception Handling 8-1 Introduction We saw in chapter 6 that an exception represents a problem with the program that results in immediate termination of the program. In this chapter, we’ll look at: >    exceptions that you’ll normally come across while writing Java programs >    checked and unchecked exceptions >    how to create custom exceptions >    how to catch exceptions and handle them gracefully Let’s look at what are exception classes and how they are used in programs. 8-2 Exception classes In Java, an exception is represented by a class. Java defines built-in exception classes representing common exception conditions. For instance, java.lang.NullPointerException  represents an exception co