Java Techies- Solution for All
Inheritance
- Inheritance is feature in OOP where you can extend a class and create a completely new object.
- The new object keep all the functionality of the parent object from which it is extended or can override.
Example :
<?php class Base { function add() { echo " Base Class function </br>"; } } Class Demo extends Base { function subtract() { echo " Derived Function "; } } $obj=new Demo(); $obj->add(); $obj->subtract(); ?>
Output :
Base Class function Derived Function