OOAD Miscellanous Q/A #2

Question:How the exception handling mechanism is useful than the normal error checking code?


Exception handling mechanism is useful/ preferred than the normal error checking codes considering the following reasons:

  1. Exception handling makes it easy to manage run time errors in a systematic manner.

  2. logical and syntactical errors can be easily corrected by the normal error checking codes but other problems like exceptions can not be debugged using normal error checking codes. Exception handling mechanism is needed for exceptions handling. Exceptions are unusual conditions that a program may encounter while executing. These unusual conditions are

    • Division by zero.

    • Accessing an element which is out of range of array.

    • Passing in a parameter which is not a valid range.

    • Attempting to use a negative size for an array.

  3. With the help of exception handling , program can automatically invoke an error handling routine when an error occurs.

  4. Execution handling is preferred because it makes it easy to separate the error handling code from the code written to handle the rest of the program.

  5. In case of the normal error check code mechanism, there is no facility to detect and handle exceptions. Thus normal error check code lacks in following:

    • Proper recovery of errors is not possible.

    • Effective management of errors is not done.

    • In brief, exception handling mechanism is useful/ preferred because
    • It manages or handles the exceptions properly.

    • It avoid the situation stopping the normal execution of programs.

    • It effectively detects the exceptional conditions.

    • It is proper method to catch all types of exceptions.

    • In this method, proper recovery of exceptions is done.

Kickstart Your Career

Get certified by completing the course

Get Started