Your SlideShare is downloading. ×
Exception Handling In Java 15734
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Exception Handling In Java 15734

1,193
views

Published on

exception-handling-in-java

exception-handling-in-java

Published in: Technology, News & Politics

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,193
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
44
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Exception Handling In Java
      • Parag Shah
      • Adaptive Software Solutions
  • 2. Introduction
    • Why is Exception Handling important
    • How errors and exceptional conditions were handled in C.
    • Approach to Exception handling in Java
  • 3. Exception Classes
    • Exceptions are objects
  • 4. Exceptions – Under The Hoods
    • What happens when an Exception is thrown
  • 5. 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)
  • 6. Throwing Exceptions
    • Creating and throwing an Exception
    • The throws clause
    • Choosing the Exception to throw
  • 7. 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
  • 8. 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)
  • 9. Runtime Exceptions (see RuntimeExceptionExample.java)
    • Runtime Exceptions are special
    • Runtime Exceptions in Java
    • When to use Runtime Exceptions
  • 10. 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
  • 11. 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
  • 12. Summary
    • Exceptions are used for improved error recovery
    • Using Exceptions appropriately will result in robust programs
    • Revisit Exception API
  • 13. 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