Vidyalelo
PHP · Q45

Object Oriented Concept

Programming · PHP · question 45

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
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
A final class cannot be subclassed. Less drastically, a final method cannot be overridden.