1/22
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Exception
Event that occurs during the execution of a program that disrupts the normal flow of instructions.
Exception Handling
The process used to change the normal flow of code execution if a specified exception occurs.
Checked Exceptions.
Exceptions that occur during compilation
ClassNotFoundException
The class is not found.
IllegalAccessException
Access to a class is denied.
InstantiationException
Attempt to create an object of an abstract class or an interface.
NoSuchMethodException
A requested method does not exist.
Unchecked Exceptions
Exceptions that occur during execution. These are also known as runtime exceptions.
ArithmeticException
Arithmetic error, such as an integer divided by 0
ArrayIndexOutOfBoundsException
Accessing an invalid index of the array
ArrayStoreException
Assigning a value to an array index that does not match the expected data type
InputMismatchException
Entering a value that does not match the expected data type
NullPointerException
Invalid use of a null reference
NumberFormatException
Invalid conversion of a string to a numeric format
StringIndexOutOfBoundsException
Accessing an invalid index (character) of a string
try block
A block of code that might throw an exception that can be handled by a matching catch
catch block
A segment of code that can handle an exception that might be thrown by the try block that precedes it.
getMessage()
Method can be used to determine Java’s message about the exception.
Syntax of getMessage ()
System.out.println(exceptionName.getMessage());
(1) try block
Is accepted in a program but there can be multiple catch blocks
User-defined exception
Created by extending the Exception class.
finally block
Statements which are executed whether or not an
throw statement
Sends an exception out of a block or a method so it can be handled elsewhere.