Exception Handling Flashcards

1
Q

What is exception

A

Exception is an unexpected problem that arises during the execution of a program

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

C++ exception handling is built upon three keywords. What are they?

A

try, throw and catch

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

What is the try statement

A

This allows you to test a block of code for errors while it is being executed

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

What is the throw statements?

A

Throw keyword throws an exception when a problem is detected. This enables us to detect custom error.

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

What is catch statement

A

This allows you to define a block of code to be executed if an error occurs in the try block

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

Mention some C++ standard exceptions

A

bad_cast:
runtime_error:
bad_exceptions
bad_typeid
logic_error
invalid_arguments
length_error
overflow_error
range_error
underflow_error

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

Differnce between runtime_error and logic_error

A

Runtime error is An exception that theoretically cannot be detected by reading the code

Logic error is an exception that theoretically can be detected by reading the code.

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

Describe bad_exceptions

A

This is a useful device to handle unexpected exceptions in a c++ programs.

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

Difference between overflow_error and underflow_error

A

overflow error is thrown if a mathematical overflow occurs

underflow error is thrown if a mathmatical underflow occurs

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