OBJECT ORIENTED
PROGRAMMING
Exception Handling
Salvatore Distefano
,Introduction
■ Exception handling
■ Exception—an indication of a problem that occurs during a program’s execution.
§ The name “exception” implies that the problem occurs infrequently.
§ An exception is an event, which occurs during the execution of a program, that disrupts
the normal flow of the program's instructions.
■ With exception handling, a program can continue executing (rather than terminating)
after dealing with a problem.
§ Mission-critical or business-critical computing.
§ Robust and fault-tolerant programs (i.e., programs that can deal with problems as they
arise and continue executing).
,Exception Handling: Processing the Incorrect
Response
■ An exception indicates a problem that occurs while a program executes.
■ The name “exception” suggests that the problem occurs infrequently—if
the “rule” is that a statement normally executes correctly, then the
problem represents the “exception to the rule.”
■ Exception handling helps you create fault-tolerant programs that can
resolve (or handle) exceptions.
, Exception Handling: Processing the Incorrect
Response (Cont.)
■ When the JVM or a method detects a problem, such as an invalid array
index or an invalid method argument, it throws an exception—that is, an
exception occurs.
PROGRAMMING
Exception Handling
Salvatore Distefano
,Introduction
■ Exception handling
■ Exception—an indication of a problem that occurs during a program’s execution.
§ The name “exception” implies that the problem occurs infrequently.
§ An exception is an event, which occurs during the execution of a program, that disrupts
the normal flow of the program's instructions.
■ With exception handling, a program can continue executing (rather than terminating)
after dealing with a problem.
§ Mission-critical or business-critical computing.
§ Robust and fault-tolerant programs (i.e., programs that can deal with problems as they
arise and continue executing).
,Exception Handling: Processing the Incorrect
Response
■ An exception indicates a problem that occurs while a program executes.
■ The name “exception” suggests that the problem occurs infrequently—if
the “rule” is that a statement normally executes correctly, then the
problem represents the “exception to the rule.”
■ Exception handling helps you create fault-tolerant programs that can
resolve (or handle) exceptions.
, Exception Handling: Processing the Incorrect
Response (Cont.)
■ When the JVM or a method detects a problem, such as an invalid array
index or an invalid method argument, it throws an exception—that is, an
exception occurs.