Exception Handling
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
Exeption | show 🗑
|
||||
show | The name for the object-oriented techniques that manage such errors
🗑
|
||||
Runtime Exception | show 🗑
|
||||
Java's Two Basic Classes of Errors | show 🗑
|
||||
Error Class | show 🗑
|
||||
show | Comprises less serious errors representing unusual conditions that arise while a program is running and from which the program can recover. For example, using an invalid array subscript or performing certain illegal arithmetic operations
🗑
|
||||
show | When a program ends prematurely with an error
🗑
|
||||
Stack Trace History List(Stack Trace) | show 🗑
|
||||
Mission Critical | show 🗑
|
||||
show | Are designed so that they continue to operate, possibly at a reduced level, when some part of the system fails
🗑
|
||||
Robustness | show 🗑
|
||||
show | Programs that handle exceptions appropriately are said to be more fault tolerant and robust
🗑
|
||||
1. Try Block | show 🗑
|
||||
show | A try block consists of the following elements...
1. The keyword try..
2. An opening curly brace..
3. Executable statements, including some that might cause exceptions..
4. A closing curly brace
🗑
|
||||
Catch Block | show 🗑
|
||||
Throw Statement | show 🗑
|
||||
Format of try...catch Pair | show 🗑
|
||||
show | Used when you have actions you must perform at the end of a try...catch sequence. The code within a finally block executes regardless of whether the preceding try block identifies an exception
🗑
|
||||
Exception Specification | show 🗑
|
||||
Java's Two Types of Exceptions | show 🗑
|
||||
show | Inherit from Error or RuntimeException class. Can be handled but you are not required to do so. For example, dividing by zero is type of RuntimeExceptio, and you are not required to handle this exception - you can simple let program terminate
🗑
|
||||
Checked Exceptions | show 🗑
|
||||
1. Catch or Specify Requirement | show 🗑
|
||||
show | 1. Catch it within the method..
2. Specify the exception in you method header's throws clause...
Code that uses a checked exception will not compile if the catch or specify rule is not followed
🗑
|
||||
show | If you write a method with a throws clause in the header, then any method that uses your method must do one of the following...
1. Catch and handle the possible exception..
2. Declare the exception in its throws clause.
🗑
|
||||
2. Writing a Method With a throws Clause in Header | show 🗑
|
||||
show | public class PriceList..
{..
private static final double[] price = {15.99, 27.88, 34.56};..
public static void displayPrice(int item) throws IndexOutOfBoundsException..
{..
System.out.println("The price is $" + price[item]);..
}..
}
🗑
|
||||
Call Stack | show 🗑
|
||||
Assertion | show 🗑
|
||||
assert Statement | show 🗑
|
||||
assert Statement Syntax | show 🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
TimJavaProgramming
Popular Engineering sets