0% found this document useful (0 votes)
2 views2 pages

Java Exception Handwritten

The document provides a quick revision of Java Exception Handling, defining exceptions as unwanted events that disrupt program flow at runtime. It categorizes exceptions into checked, unchecked, and errors, and explains the use of keywords like try, catch, finally, throw, and throws. Key points include that only one catch block executes, the finally block always runs, and the order of catch blocks should be from specific to general.

Uploaded by

namithad115
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Java Exception Handwritten

The document provides a quick revision of Java Exception Handling, defining exceptions as unwanted events that disrupt program flow at runtime. It categorizes exceptions into checked, unchecked, and errors, and explains the use of keywords like try, catch, finally, throw, and throws. Key points include that only one catch block executes, the finally block always runs, and the order of catch blocks should be from specific to general.

Uploaded by

namithad115
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Exception Handling – Quick Revision Sheet

1. What is an Exception?
• An unwanted event disrupting program flow
• Occurs at runtime
• Example: divide by zero, invalid index

2. Types of Exceptions
• Checked – compile-time (IOException)
• Unchecked – runtime (ArithmeticException)
• Errors – serious (OutOfMemoryError)

3. Keywords
• try – risky code
• catch – handle exception
• finally – always executes
• throw – create exception
• throws – declare exception

4. try-catch Example
try {
int a = 10/0;
} catch(Exception e){
[Link]("Error");
}

5. Multiple Catch
try {
int arr[] = new int[2];
arr[5]=10;
} catch(ArithmeticException e){
[Link]("Arithmetic");
} catch(ArrayIndexOutOfBoundsException e){
[Link]("Array Error");
} catch(Exception e){
[Link]("General");
}

6. finally Block
finally {
[Link]("Always runs");
}

7. throw & throws


throw new ArithmeticException();

void test() throws IOException {}

8. Key Points
• Only one catch executes
• Order: specific → general
• finally always runs
• Checked must be handled
• Unchecked optional

Memory Trick
• Try Catch Finally Throw Throws (T-C-F-T-T)
• One try, many catches, first match executes

You might also like