Lesson 13: Exceptions Flashcards

1
Q

What is error - checking code?

A

Code that a programmer introduces to detect and handle errors that occur while the program executes

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

What is the purpose of exception handling constructs?

A

They handle exceptional circumstances, or errors, during execution

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

What kind of code is placed in a “try” block?

A

Code that potentially may produce an exception.

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

When is an “except” block” used?

A

If the code in the try block causes an exception

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

What causes an unhandled exception to occur?

A

No exception handler existing for an error type

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

What does the interpreter do when it encounters an unhandled exception?

A

Print the exception that occurred and halt

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

When is a “raise” statement executed?

A

When code detects an error

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

What happens when a “raise” statement executes?

A
  1. Immediate exit from the try block and the execution of an exception handler
  2. The exception handler prints the argument passed by the raise statement that brought execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the “as” keyword do?

A

Binds a name to the exception being handled

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

What does the “finally” clause in a try statement do?

A

Allows a programmer to specify clean - up actions that are always executed-

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