Bird
0
0

Which statement about custom exception classes in PHP is TRUE?

hard📝 Conceptual Q10 of 15
PHP - Error and Exception Handling

Which statement about custom exception classes in PHP is TRUE?

ACustom exceptions must override the <code>getMessage()</code> method
BCustom exceptions do not support constructor arguments
CCustom exceptions can add new properties and methods for extra error info
DCustom exceptions cannot be caught by catch blocks for <code>Exception</code>
Step-by-Step Solution
Solution:
  1. Step 1: Review custom exception capabilities

    Custom exceptions can add properties and methods to provide extra error information.
  2. Step 2: Evaluate each statement

    A is false because overriding getMessage() is optional. B is false because constructors can accept arguments. C is false because custom exceptions extend Exception and can be caught by it. D is true.
  3. Final Answer:

    Custom exceptions can add new properties and methods for extra error info -> Option C
  4. Quick Check:

    Custom exceptions extend Exception and add features [OK]
Quick Trick: Custom exceptions extend Exception and add custom features [OK]
Common Mistakes:
  • Thinking getMessage() must be overridden
  • Believing custom exceptions can't be caught by Exception
  • Assuming constructors can't have arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes