Exception Handling Flashcards

(27 cards)

1
Q

An ____ is an ____or unexpected ____ that happens while the program is running.

A

exception, error, situation

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

What are the common Causes of Exception Handling

A
  • The program asks for input, but the user enters the wrong type of data (e.g., text instead of a number).
  • The program tries to divide a number by
    zero, which is not allowed in math.
  • The program accesses an array index that doesn’t exist (e.g., using a negative index or going beyond the last element).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why are they called “Exceptions”?

A

They are unusual cases, or
“exceptions” to the usual process.

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

________ refers to techniques that Java uses to ____, ____, and respond to _____ in a controlled way.

A

Exception handling, detect, handle, errors.

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

Exception Handling uses ________ concepts to manage these problems.

A

object-oriented programming (OOP)

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

A ________ happens while the program is running.

A

runtime exception

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

A ______ is a mistake in the code structure, like missing a semicolon, and is found _____ the program runs (during compilation).

A

syntax error, before

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

What are the two types of main classes Java handles?

A

Exception and Error

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

Both of these classes come from a ______ called _______, and like all Java classes, they also come from the base class ______.

A

parent class, Throwable, Object

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

This represents serious system-level problems. These are issues that the program cannot fix by itself.

A

Error Class

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

This represents serious system-level problems. These are issues that the program cannot fix by itself.

A

Exception Class

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

What happens when a Java program could have avoided a problem but didn’t?

A

Java throws an Exception and displays an error message.

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

What does Java do if a program tries to divide by zero?

A

Java throws an ArithmeticException.

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

How many categories of Exceptions does Java acknowledges?

A

More than 75 exceptions

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

What Is a Crash in Programming?

A

A crash means that the program stops running suddenly because of an error.

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

What happens when a program crashes?

A

User will see an error message and the program will stop before completing its task

17
Q

A list of method calls shown in the error message is called a _______.

18
Q

A _____ means that the program ________ because of an _____.

A

crash, stops running suddenly, error

19
Q

This shows the sequence of method calls that led to the error.

20
Q

The term originally referred to physical problems with hard drives but now applies to software errors too.

21
Q

This helps programmers locate and understand where the problem happened.

22
Q

What kind of program keeps running even if something goes wrong, possibly reducing performance or features without crashing?

A

fault-tolerant program

23
Q

What kind of program can handle unexpected problems and remain more reliable under stress or errors?

A

robust program

24
Q

With _______ makes your program safer, smarter, and user-friendly.

A

Exception handling

25
In object-oriented programming, what happens when something goes wrong during program execution, and how can you handle the problem properly using special code?
an exception is thrown, and You can write special code “try” to “catch” the exception and handle the problem properly.
26
How can a try block help prevent crashes caused by incorrect user input, such as when a user enters a letter instead of a number in a nextInt() method?
With a try block, you can catch such input mistakes and handle them properly.
27