Program Error Types and Basic Exception Handling
Program Error Types and Basic Exception Handling
9.1 - iNTRODUCTION
What is exceptional handling ?
Java Supports a specific and well defined
mechanism of catching and preventing errors of
any type that may occur.
9.2 - TYPES OF PROGRAM ERRORS
There are three types of errors they are:
9.2.1 - COMPILE TIME ERROS -
Error that occur during the compilation.
There are two types of compile time errors they are ;
Syntax error and semantic error
Syntax error - when rules of programming language is
misused.
Semantic error - when the statements are not
meaningful.
9.2.2 - RUN TIME ERRORS -
it occurs during the execution of the program.
9.2.3 - logical errors -
It occurs due to the mistake of programmers analysis.
CH - 9 - SONG
handling logical errors -
Desk checking and dry run - it is a step by step process
that check every lines and their looping conditions.
Inserting tracing statements.
Using an Interactive debugger.
9.3 - exception and exception handling -
Exception - Unexpected error during program execution.
Exception handling - Way of handling unexpected
situations in a program run.
Throwing - The raising of imaginary error flag.
Catching - when an error is thrown the overall system
responds by catching it.
Try - Surrounding a block an error sensitive code with
exceptional handling.
Catch clause (or) catch block - The block of code that
attempts to deal with the exception.
Stack trace - The sequence of method calls that brought
control to the point where the exception occurred.
Throws clause - Indicating that if an exception occurs, it
will automatically report it to error handle or processor.
Common exceptions -
ArithmeticException
ArrayIndexOutOfBoundsException
CH - 9 - SONG
StrindIndexOutOfBoundsException
NullPointerException
NumberFormatException
ClassNotFoundException
IOException