Exception Handling

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/16

flashcard set

Earn XP

Description and Tags

Flashcards on Exception Handling in Java

17 Terms

1
New cards

Exception

An error event that occurs during program execution, preventing normal continuation.

2
New cards

Exception Handling

Allows a program to manage exceptions and recover from errors.

3
New cards

Common causes of exceptions in Java

Numeric overflow, type conversion, dividing by zero, file not found, running out of memory, SQL errors, array bounds, null object.

4
New cards

Approaches to Error Checking

Handle errors appropriately for every error, do normal processing in one place and handle errors in another.

5
New cards

Important methods of the Exception class

printStackTrace(), getMessage(), getLocalizedMessage(), toString()

6
New cards

java.lang.Exception

All exceptions are derived from this class.

7
New cards

Throwing an exception

The creation of an object representing an error.

8
New cards

Handling an exception

The code that detects and manages the exception.

9
New cards

Common Exception Types

NullPointerException, ClassCastException, ArithmeticException, NumberFormatException, IOException, FileNotFoundException, EOFException.

10
New cards

Try-Catch Structure

A control structure used to separate normal code from error-handling code.

11
New cards

Components of Try-Catch Structure

try, catch, finally

12
New cards

Ordering Catch Statements

The order in which catch statements should be arranged from most specific to most general.

13
New cards

Checked Exception

An exception the compiler can recognize, requiring a throws statement.

14
New cards

Unchecked Exception

An exception the compiler cannot determine at compile time, not requiring a throws statement.

15
New cards

Throw statement

Used to create an exception in your program.

16
New cards

Throws statement

A method throws exceptions using this statement.

17
New cards

When to throw an exception in your code

When an object of the class or class methods aren’t used properly, when a method encounters a situation where it’s unable to complete its task, when you want to generate an exception to test an exception handler.