Exception Handling In Java
Upcoming SlideShare
Loading in...5

Exception Handling In Java



These slides explain how Java supports Exception handling

These slides explain how Java supports Exception handling



Total Views
Views on SlideShare
Embed Views



8 Embeds 134

http://www.slideshare.net 49
http://indijava.in 26
http://static.slideshare.net 21
http://www.indijava.in 17
http://www.brijj.com 15
http://www.techiegyan.com 3
http://localhost 2
http://dev.toeska.cl 1


Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.


11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here

  • sir I forget my login name or password please tell me
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Exception Handling In Java Exception Handling In Java Presentation Transcript

    • Exception Handling In Java
        • Parag Shah
        • Adaptive Software Solutions
    • Introduction
      • Why is Exception Handling important
      • How errors and exceptional conditions were handled in C.
      • Approach to Exception handling in Java
    • Exception Classes
      • Exceptions are objects
    • Exceptions – Under The Hoods
      • What happens when an Exception is thrown
    • Dealing With an Exception
      • Catching the Exception
        • The try - catch block
            • Single catch (see SimpleException.java)
            • Multiple catch (see SimpleExceptions.java)
            • Using both parent & subclass in catch clause
            • Always catch the appropriate Exception
        • Termination vs Resumption of program control
      • Propagating the Exception (see ThrowingAndPropagating.java)
      • Exception chaining (see ExceptionChaining.java)
    • Throwing Exceptions
      • Creating and throwing an Exception
      • The throws clause
      • Choosing the Exception to throw
    • Creating Custom Exceptions (see MyException.java)
      • When do we need to create custom Exceptions
      • Extend an Exception class
          • Extend Exception
          • Extend a subclass of Exception
      • Override constructors
      • The name says it all
      • Approaches to Exception creation
          • Using a generic Exception with different messages
          • Using different Exception classes
          • Adding additional objects to the Exception
    • Exception Specification
      • Methods which throw an Exception must define them using the throws clause
      • Runtime Exceptions need not be defined using the throws clause
      • java.lang.Exception API
      • Standard Java Exceptions
      • Using Exception in overriden methods (will not allow)
    • Runtime Exceptions (see RuntimeExceptionExample.java)
      • Runtime Exceptions are special
      • Runtime Exceptions in Java
      • When to use Runtime Exceptions
    • The finally clause (see Finally.java)
      • The finally is used to perform cleanup after an Exception is thrown
      • When is finally called
      • The lost Exception
      • Finally without a catch
    • Best Practices with Exceptions
      • Do not catch an Exception if you cannot deal with it
      • Always use finally to perform clean up activities
      • Name custom Exceptions appropriately
      • Add appropriate messages to Exceptions
      • Do not throw too many Exceptions from a method
      • Use Wrappers where necessary
    • Summary
      • Exceptions are used for improved error recovery
      • Using Exceptions appropriately will result in robust programs
      • Revisit Exception API
    • Where to Get More Information
      • http://www.adaptivelearningonline.net/adaptivecourses/2006/7/28/exception-handling.html
      • Thinking In Java – chapter on “Error Handling With Exceptions”
      • http://java.sun.com/docs/books/tutorial/essential/exceptions/
      • Google: Java exception best best practices