Loading…

What are the final class and final method?

Its properties cannot be declared final, only classes and methods may be declared as final. If the class or method defined as final, then it cannot be extended.

Example

                                        

class childClassname extends parentClassname {
    protected $numPages;

    public function __construct($autor, $pages) {
       $this->_autor = $autor;
       $this->numPages = $pages;
    }

    final public function PageCount() {
       return $this->numPages;
    }
}

Suggest An Answer

No suggestions avaliable!

Latest post from PHP interview questions

Ask Question