Error management and exception handling

39 %
61 %
Information about Error management and exception handling
Entertainment

Published on October 23, 2014

Author: arunkumarm526

Source: authorstream.com

Error management and exception handling JAVA : Error management and exception handling JAVA BY: VINAY C (12YCSB6043) B C A 5 th Sem INTRODUCTION: INTRODUCTION A program rarely run successfully at its very first attempt, Errors are the wrong that can make a program go wrong. It is therefore important to detect and manage properly all the possible error condition in the program so that the program will not terminate or crash during execution. Errors: Errors Errors are classified into two categories : Compile-time errors Run-time errors Compile-time errors :- All syntax errors will be detected and displayed by the java compiler and therefore these errors are known as compile time errors Run-time errors :- Run time errors are type of errors which are occurred by dividing an integer by zero, trying to cast an instance of a class to one of its sub class Error may occurred in execution time . Abnormal termination of program . Wrong execution result. Exception: Exception Definition :- An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following: A user has entered invalid data. A file that needs to be opened cannot be found. Exception Hierarchy: Exception Hierarchy All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class The Exception class has two main subclasses: IOException class and Runtime Exception Class.. Exceptions: Exceptions IO Exceptions Runtime Exceptions IO Exceptions IOException is any unexpected problem the compiler encounters while attempting to run a program. Possible problems the compiler may encounter are attempting to read from a file that does not exist, write to a file which has an invalid name (a slash or a question mark in the title should do it), or attempting to read the next token in a file when there are no more tokens. Runtime exception A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compilation. Catching Exceptions: Catching Exceptions A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. try/catch looks like the following: Try { //Protected code } catch( ExceptionName e1) { //Catch block } The finally Keyword: The finally Keyword The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred. A finally block appears at the end of the catch blocks and has the following syntax: try { //Protected code } catch(ExceptionType1 e1) { //Catch block } catch(ExceptionType2 e2) { //Catch block } catch(ExceptionType3 e3) { //Catch block } Finally { //The finally block always executes. } Common Exceptions: Common Exceptions JVM Exceptions Programmatic exceptions JVM Exceptions : - These are exceptions/errors that are exclusively or logically thrown by the JVM. Examples : NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException, Programmatic exceptions : - These exceptions are thrown explicitly by the application or the API programmers Examples: IllegalArgumentException, IllegalStateException. PowerPoint Presentation: THANK YOU

Add a comment

Related presentations

Related pages

Exception handling - Wikipedia, the free encyclopedia

Alternative approaches to exception handling in software are error ... Automated exception handling; Exception ... based Workflow Management" by Gert ...
Read more

Lesson: Exceptions (The Java™ Tutorials > Essential Classes)

Catching and Handling Exceptions. ... An exception is an ... The use of exceptions to manage errors has some advantages over traditional error-management ...
Read more

Exception management and error tracking in J2EE | JavaWorld

The perpetual debate on exception handling in Java can at best be described as a religious war: On one side, you have the proponents of checked exceptions ...
Read more

3 - Error Management Made Exceptionally Easy: Using the ...

About Exception Handling Policies. Each policy you configure for the Exception Handling block can specify one or more exception types, such as ...
Read more

Exception Handling Application Block

Exception Handling Application Block. Enterprise Library. patterns & practices Developer Center. Microsoft Corporation. May 2007. Summary. This section ...
Read more

ASP.NET Error Handling | The ASP.NET Site

Application Lifecycle Management: ... Adding Application-Level Error Handling. Rather than trap the exception using ... You're Viewing ASP.NET Error Handling
Read more

Ausnahmebehandlung – Wikipedia

... {// Ein Error ist keine Exception und muss separat abgefangen werden e. printStackTrace ();} ... (Structured Exception Handling) Errors and Exceptions.
Read more