Q45
What will be the output of the following PHP code? class Checkout final function totalize() // calculate bill class IllegalCheckout extends Checkout final function totalize() // change bill calculation
A.
PHP Fatal error: Class IllegalCheckout may not inherit from final class
B.
Value of the bill calculated
C.
PHP Fatal error: Cannot find object
D.
PHP Fatal error: Cannot override final method
AnswerAnswer: Option D
Solution
Answer: Option D
Solution:
A final class cannot be subclassed. Less drastically, a final method cannot be overridden.