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:

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation