Exceptions Flashcards

1
Q

How many corresponding catch or finally blocks can a try block have?

A

It must have at least one.

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

What are the limitations on objects thrown via a try/catch block?

A

The thrown object must be an instance of the Exception class or a subclass of Exception. Otherwise, a fatal error will result.

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

What happens when an exception is thrown but not caught?

A

A php fatal error will be issued with an “Uncaught Exception…” message, unless a handler has been defined with set_exception_handler().

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

What is a ‘finally’ block?

A

In php 5.5 and later, a finally block may be specified after or instead of catch blocks. Code within the finally block will always be executed after the try and catch blocks, regardless of whether an exception has been thrown, and before normal execution resumes.

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

Do functions use exceptions?

A

No, they use Error Reporting. However, errors can be simply translated to exceptions with ErrorException.

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

Can Exceptions be cloned?

A

No. Attempting to clone an Exception would result in a fatal E_ERROR error.

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

If a class extends the built-in Exception class and redefines the construction, it is highly recommend to…

A

…also call parent::__construct() to ensure all available data has been properly assigned.

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