Read Also: Top 20 MCQ Questions on Error Handling in PHP
1) There are … methods available to the exception class in PHP.
A. 5
B. 6
C. 7
D. 8
2) Which of the following is the correct order of the steps for implementing the exception handling process.
i. If the attempt fails, the exception-handling feature throws an exception.
ii. The application attempts to perform some task.
iii. The exception handling feature cleans-up any resources consumed during the attempt.
iv. The assigned handler catches the exception and performs any necessary tasks.
A. ii, i, iii and iv
B. ii, i, iv and iii
C. iv, ii, i and iii
D. i, ii, iii and iv
3) In PHP’s exception handling, the overloaded constructor offers additional functionality through the acceptance of the following optional parameters.
i. message
ii. error code
iii. previous
iv. next
A. i, ii and iii only
B. ii, iii and iv only
C. i, iii and iv only
D. All i, ii, iii and iv
4) The method …. in exception class will return an array consisting of information pertinent to the context in which the error occurred.
A. getArray()
B. getMessage()
C. getTrace()
D. getString()
5) The getPrevious() method in exception class was added in …
A. PHP 5.2
B. PHP 5.3
C. PHP 5.4
D. PHP 6
6) The standard PHP library offers access to … predefined exceptions.
A. 12
B. 13
C. 14
D. 15
7) The … class should be used to handle scenarios where an input value falls outside of a range.
A. DomainException
B. OutOfRangeException
C. OutOfBoundsException
D. OverflowException
8) The … class should be used to handle a function’s output values that fall outside of a predefined range.
A. DomainException
B. OutOfRangeException
C. OutOfBoundsException
D. OverflowException
9) The … class should be used to handle situations where a provided value does not match any of an array’s defined keys.
A. UnexpectedValueException
B. OutOfRangeException
C. DomainException
D. OutOfBoundsException
10) The … class should be used to handle situations where an arithmetic or buffer overflow occurs.
A. DomainException
B. OutOfRangeException
C. OutOfBoundsException
D. OverflowException
11) The … class should be used to handle situations where a provided value does not match any of a predefined set of values.
A. UnexpectedValueException
B. OutOfRangeException
C. DomainException
D. OutOfBoundsException
12) Which of the following are the methods available to the exception class in PHP.
i. getCode()
ii. getLine()
iii. getString()
iv. getTrace()
A. i, ii and iii only
B. ii, iii and iv only
C. i, ii and iv only
D. All i, ii, iii and iv
13) The … class is used when performing an invalid operation on an empty container, such as removing an element.
A. BadFunctionCallException
B. BadMethodCallException
C. RangeException
D. UnderflowException
14) State whether the following statements about the RangeException class is TRUE or FALSE.
i. It indicates the range of errors during program execution.
ii. There was an arithmetic error other than under/overflow.
ii. This is the compile-time version of DomainException.
A. i-True, ii-False, iii-True
B. i-True, ii-False, iii-False
C. i-True, ii-True, iii-True
D. i-True, ii-True, iii-False
15) … handles exceptions due to value being too small to maintain precision, resulting in loss of accuracy.
A. BadFunctionCallException
B. BadMethodCallException
C. RangeException
D. UnderflowException
16) The … class is used if a callback refers to an undefined method or if some arguments are missing.
A. BadFunctionCallException
B. BadMethodCallException
C. RangeException
D. UnderflowException
17) The … class is used if a callback refers to an undefined function or if some arguments are missing.
A. BadFunctionCallException
B. BadMethodCallException
C. RangeException
D. UnderflowException
18) … class handles the situations where an application is programmed incorrectly, such as when there is an attempt to invoke a method before a class attribute has been set.
A. LengthException
B. LogicException
C. RangeException
D. UnderflowException
19) The … class is used to handle arithmetic errors unrelated to overflow and underflow.
A. BadFunctionCallException
B. BadMethodCallException
C. RangeException
D. UnderflowException
20) The … class should be used to handle situations where an argument of an incompatible type is passed to a function or method.
A. LengthException
B. LogicException
C. RangeException
D. InvalidArgumentException
Answers
- C. 7
- B. ii, i, iv and iii
- A. i, ii and iii only
- C. getTrace()
- B. PHP 5.3
- B. 13
- A. DomainException
- B. OutOfRangeException
- D. OutOfBoundsException
- D. OverflowException
- A. UnexpectedValueException
- C. i, ii and iv only
- D. UnderflowException
- D. i-True, ii-True, iii-False
- D. UnderflowException
- B. BadMethodCallException
- A. BadFunctionCallException
- B. LogicException
- C. RangeException
- D. InvalidArgumentException
Read Next: Top 20 MCQ Questions on POSIX Regular Expressions in PHP
Comments are closed.