Web Designing MCQs

Top 20 MCQ Questions on Exception Handling in PHP

Pinterest LinkedIn Tumblr
Here are the collections of top 20 MCQ questions on exception handling in PHP includes multiple-choice questions on fundamentals of exception handling in PHP. It includes MCQ questions on the different methods available to the exception class in PHP, ways of extending the exception base class, predefined exceptions offered by the standard PHP library.

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

  1. C. 7
  2. B. ii, i, iv and iii
  3. A. i, ii and iii only
  4. C. getTrace()
  5. B. PHP 5.3
  6. B. 13
  7. A. DomainException
  8. B. OutOfRangeException
  9. D. OutOfBoundsException
  10. D. OverflowException
  11. A. UnexpectedValueException
  12. C. i, ii and iv only
  13. D. UnderflowException
  14. D. i-True, ii-True, iii-False
  15. D. UnderflowException
  16. B. BadMethodCallException
  17. A. BadFunctionCallException
  18. B. LogicException
  19. C. RangeException
  20. D. InvalidArgumentException

Read Next: Top 20 MCQ Questions on POSIX Regular Expressions in PHP

Please follow and like us:
RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
linkedIn | Top 20 MCQ Questions on Exception Handling in PHP
Share

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.

RSS
Follow by Email
X (Twitter)
Visit Us
Follow Me
YouTube
YouTube
LinkedIn
Share