Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Java
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share

Start Learning Now

Our free lessons will get you started (Adobe Flash® required).
Get immediate access to our entire library.

Sign up for Educator.com

Membership Overview

  • Unlimited access to our entire library of courses.
  • Search and jump to exactly what you want to learn.
  • *Ask questions and get answers from the community and our teachers!
  • Practice questions with step-by-step solutions.
  • Download lesson files for programming and software training practice.
  • Track your course viewing progress.
  • Download lecture slides for taking notes.
  • Learn at your own pace... anytime, anywhere!

Exception Handling

  • An error that arises through mistakes in coding or through incorrect data entered by the user is called an “exception”
  • Such errors that are encountered while a program runs are said to be “thrown”
  • Programmers try to anticipate these errors and either prevent or solve them before they happen
  • Java uses the “Try... Catch...” process in order to try running a block of code to test for errors and then catch an error if it occurs
  • All “Try” statements must be followed by at least one “Catch” statement or a “Finally” statement
  • Exceptions that occur that are not handled by a “Catch” block of code or a “Finally” block will cause a program to terminate

Exception Handling

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • What is Exception Handling? 0:09
    • Definition of Exception Handling
  • Why Account for Errors? 1:31
    • Why Account for Errors?
  • Common Types of Errors 3:51
    • User Caused
    • Programmer or System Caused
  • Using the 'Try… Catch' Process 7:30
    • Try
    • Catch
  • Try… Catch Syntax 8:51
    • Try… Catch Syntax
  • Uncaught Exceptions 9:44
    • Handling Uncaught Exceptions
  • Throw' Statement 11:03
    • Throw Statement
    • Throw Syntax
  • Example 1: Program to Catch Divide by Zero Error 11:41
  • Example 2: Program to Demonstrate Finally Keyword 16:18
  • Example 3: Superclass and Subclass Exceptions 19:20