Examveda
Examveda

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: Option D

Solution(By Examveda Team)

A final class cannot be subclassed. Less drastically, a final method cannot be overridden.

This Question Belongs to PHP >> Object Oriented Concept

Join The Discussion

Related Questions on Object Oriented Concept