[Audio] Hello, today's topic is exception handling in Java© Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Exception is an unwanted or unexpected event, which occurs during the execution of a program, i.e. at run time, that disrupts the normal flow of the program's instructions. When an exception occurs within a method, it creates an object. This object is called the exception object. It contains information about the exception, such as the name and description of the exception and the state of the program when the exception occurred. Java Exception Handling is a mechanism to handle runtime errors such as ClassNotFoundException, IOException, SQLException, RemoteException, etc © Copyright Showeet.com – Free PowerPoint Templates.
[Audio] Here we've reason why exceptions in java occur 1 because of invalid user input, second is because of device failure , they may occur due to loss of network connections, physical limitations like no space to store or perform operation, the exception may occur due to code errors, and opening an unavailabe file is also an Exception© Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] In this slide we can see the difference between Error and Exception. Error: An Error indicates a serious problem that a reasonable application should not try to catch. And Exception indicates conditions that a reasonable application might try to catch. © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Advantages of Exception Handling in Java. Provision to Complete Program Execution One of the important purposes of exception handling in Java is to continue program execution after an exception is caught and handled. The execution of a Java program does not terminate when an exception occurs. Once the exception is resolved, program execution continues till completion. Easy Identification of Program Code and Error-Handling Code The use of try/catch blocks segregates error-handling code and program code making it easier to identify the logical flow of a program. Propagation of Errors Java's exception handling mechanism works in such a way that error reports are propagated up the call stack. This is because whenever an exception occurs, Java's runtime environment checks the call stack backwards to identify methods that can catch the exception. Meaningful Error Reporting The exceptions thrown in a Java program are objects of a class. Identifying Error Types Java provides several super classes and sub classes that group exceptions based on their type © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Here we can see the hierarchical structure. In the next slide we're going to learn about types of exceptions in java © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Types of Exceptions are classified into two types User-defined and Built-in Exceptions As we can see Built-in exceptions are classified into 2 types, checked and un-checked Exceptions. © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Checked & Un-Checked Exceptions. Checked Exceptions: Checked exceptions are called compile-time exceptions because these exceptions are checked at compile-time by the compiler. Example: IOException, ClassNotFoundException. Unchecked Exceptions: The unchecked exceptions are just opposite to the checked exceptions. The compiler will not check these exceptions at compile time. Example: ArthmeticException, NullPointerException © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Read the table content to know exception-keywords © Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] Here is an example program on exception handling.© Copyright Showeet.com – Creative & Free PowerPoint Templates.
[Audio] © Copyright Showeet.com – Creative & Free PowerPoint Templates.