• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Exceptions in Java
 

Exceptions in Java

on

  • 526 views

This presentation provide a detailed introduction about Exceptions and Exception Handling in Java.

This presentation provide a detailed introduction about Exceptions and Exception Handling in Java.

Statistics

Views

Total Views
526
Views on SlideShare
526
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

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.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Exceptions in Java Exceptions in Java Presentation Transcript

    • EXCEPTIONS Exception is an occurrence that alters the normal program flow. Program terminates when an exception is thrown. To avoid from this, we must handle the exceptions. Try block & Catch clause.
    • Normal format of exception handling try{ risky code }catch (Name of Exception){ What to do if an exception is thrown }
    • Finally Block Definitely Executes Try must be followed by, 1. a catch clause 2. many catch clauses 3. a finally block 4. catch clauses and a finally block No code between try and catch
    • Exception Class Java.lang.Exception All Exceptions are sub classes of the class Exception Creating our own Exception by extending the class Exception The Keyword throw
    • Exception Hierarchy Throwable Exceptions Runtime Exception Interrupted Exception Arithmetic Exception Errors Stackoverflaw Error Assertion Error
    • Errors Errors represent unusual situations that have not caused by the program. Normally we cannot recover from them. So we don’t handle errors.
    • Using multiple catches &Trys Catches must be in the same order as exception hierarchy (sub class to super class) Largest catch must be the last. Some exceptions cannot use without a risk. eg:-IOException,InterruptedException Multiple trys & trys inside try is possible.
    • Checked & Unchecked Exceptions Some Exceptions are checked in compile time. RuntimeExceptions and it’s subclasses are unchecked. Others are checked in compile time. The keyword throws is used to guard risky methods. It’s not handling &just passing the bulk.
    • Re throwing Exceptions We can re throw exceptions from the catch clause. Can give a try-catch from within a catch clause. Cannot use the same Exception name in re throwing.
    • JVM & Programmatically thrown Exceptions JVM exceptions – either exclusively or most logically thrown by JVM. Eg:- nullpointer exception Programmatic – thrown by application and/or programmer. Eg:- NumberformatException, IllegalArgumentException