2016-07-18

Inheritance in java

Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object.
Benefits of inheritance

  • reuse of methods 
  • reuse of fields of parent class 
  • We can add new methods and fields
Syntax

  1. public class className extends ParentclassName  
  2. {  
  3.    //methods and fields  
  4. }  
Example:

1 comment: