SOEN6441.lab11.exception-handling.2021.4.pptx - Exception...

This preview shows page 1 - 5 out of 11 pages.

Exception Handling ADVANCED PROGRAMMING PRACTICES
Agenda What is Exception Handling? Advantages of Exception Handling Types of Java Exception Java Exception keywords Exception Handling in Java – Useful Methods Stack Unwinding Constructor Exception Boiler Example
What is Exception Handling Exception Handling is a mechanism to handle runtime errors. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled. An exception can occur for many different reasons. Following are some scenarios where an exception occurs. A user has entered an invalid data. A file that needs to be opened cannot be found. A network connection has been lost in the middle of communications or the JVM has run out of memory.
Advantage of Exception Handling 1. Maintain the normal flow of the application 2. Separating Error-Handling Code from "Regular" Code 3. Propagating Errors Up the Call Stack 4. Grouping and Differentiating Error Types

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture