Error and Exception Handling Flashcards

1
Q

What are Errors in Java?

A

Serious, unrecoverable issues often caused by runtime, hardware, or software failures. Examples:
OutOfMemoryError
StackOverflowError
VirtualMachineError

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Exceptions in Java?

A

Recoverable issues arising during program execution, such as:
NullPointerException
ArrayIndexOutOfBoundsException
FileNotFoundException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Hierarchy of Errors and Exceptions?

A

Both inherit from the Throwable class, the root of the exception hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference Between Checked and Unchecked Exceptions?

A

Checked Exceptions:

External issues (e.g., file/network errors).
Must be handled using try-catch or declared with throws.
Examples: IOException, FileNotFoundException.
Unchecked Exceptions:

Programming errors (e.g., invalid arguments).
Handling not enforced by the compiler.
Examples: NullPointerException, ArithmeticException.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Purpose of finally Block?

A

Executes crucial code (e.g., cleanup tasks) after try and catch, regardless of exceptions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly