MCQ

PHP Questions and Answers – Exception Handling

This collection of PHP Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer focuses on “Exception Handling”.
 

1. Which PHP version provide Exception handling?

A PHP 6

B PHP 5.3

C PHP 5

D PHP 4

C
Exception handling was provided with the version 5, and enhanced with version 5.3.

 

 

2. In PHP there are ____ error levels.

A 17

B 16

C 15

D 14

B
There are 16 error levels in PHP.

 

 

3. What is the intent of try block?

A It introduce block of code in which exception can arise.

B It is used instead of catch block or after catch block.

C It is used to throw an exception.

D None of the above

A
It introduce block of code in which exception can arise.

 

 

4. What is the intent of finally block?

A It introduce block of code in which exception can arise.

B It is used instead of catch block or after catch block.

C It is used to throw an exception.

D None of the above

B
It is used instead of catch block or after catch block.

 

 

5. What is the intent of throw block?

A It introduce block of code in which exception can arise.

B It is used instead of catch block or after catch block.

C It is used to throw an exception.

D None of the above

C
It is used to throw an exception.

 

 

6. Which of the following declaration invoke the exception class?

A throws new Exception();

B throw new Exception();

C new Exception();

D new throws Exception();

B
throw new Exception(); invoke the exception class.

 

 

7. Why using Exception Handling in PHP?

A To separate the error handling code from normal code

B Grouping of error types

C Both A And B

D None of the above

C
Exception Handling in PHP is used to separate the error handling code from normal code and to groupe the error types.

 

 

8. Which is not a specific keywords in exception handling?

A this

B try

C catch

D throw

A
this is not a specific keywords in exception handling.

 

 

9. What is the explanation of Error level E_ERROR?

A Fatal Compile-time error

B Fatal run-time error

C Compile-time error

D Near-fatal error

B
A Fatal run-time error is the explanation of Error level E_ERROR.

 

 

10. Which of the following are an exception in PHP?

A UnderflowException

B OverflowException

C OutOfRangeException

D OutOfBoundException

A, B, C, D
The exception is thrown if a value is not valid. UnderflowException, OverflowException, OutOfRangeException, OutOfBoundException are valid exceptions in PHP.

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *