Nov 29 2009

Java Tutorial : Exception-Handling – Summary

Category: Javaalexi @ 12:11 pm
  • Errors can be broadly categorized into two groups on the basis of whether the compiler is able to handle the error or not, such as compile time errors and runtime errors.
  • An exception is a run-time error that can be defined as an abnormal event that occurs during the execution of a program and disrupts the normal flow of instructions.
  • In Java, the Throwable class is the superclassof all the exception classes. It is the class at the top position in the exception class hierarchy. The Exception class and the Error class are two direct subclasses of the Throwable class.
  • The built-in exceptions in Java are divided into two types on the basis of the conditions where the exception is raised:
    • Checked Exceptions or Compiler-enforced Exceptions
    • Unchecked exceptions or Runtime Exceptions
  • You can implement exception-handling in your program by using the following keywords:
    • try
    • catch
    • throw
    • throws
    • finally
  • You use multiple catch blocks to throw more than one type of exception.
  • The finally clause is used to execute the statements that need to be executed whether or not an exception has been thrown.
  • The throw statement causes termination of the normal flow of control of the
  • Java code and stops the execution of subsequent statements after the throw statement.
  • The throws clause is used by a method to specify the types of exceptions the method throws.
  • You can create your own exception classes to handle the situations specific to an application.
  • You can use assertions to check and ensure that any assumption made at the start of a program is true throughout the program.
  • Exception-Handling related Tutorial Article

    1. Java Tutorial : Exception Handling
    2. Java Tutorial : Exception Classes
    3. Java Tutorial : Built-in Exceptions
    4. Java Tutorial : Implementing Exception Handling
    5. Java Tutorial : Implementing Exception Handling – Part 2
    6. Java Tutorial : Throwing An Exception – Part 1
    7. Java Tutorial : Throwing An Exception – Part 2
    8. Implementing User Defined Exceptions
    9. Java Tutorial : Assertion In Java

    Tags: , , , , , ,