What are the Final class and Final methods?
Final Class- A class that can’t be extended and inherited further is known as Final Class. This class is declared with the keyword final and should be declared.
Final Method- Methods in the final class are implicitly final and if a user uses the final keyword that means methods can’t be overridden by subclasses.
BY Best Interview Question ON 03 Nov 2021
Example
class childClassname extends parentClassname {
protected $numPages;
public function __construct($author, $pages) {
$this->_author = $author;
$this->numPages = $pages;
}
final public function PageCount() {
return $this->numPages;
}
}