Tuesday 17 June 2014

Syntax to inherit in Java

Syntax to inherit in Java

-To inherit a class in Java " extends " keyword is used.
-Syntax : 
class <Derive> extends <Base>
-From the view of derive class there are three categories of methods in base class :
1. Constructors :
~ To call constructor of  base class " super " keyword is used.
~Syntax :
   super(< argument >);
~Only derive class constructor can call the constructor of base class that too in first line of derive class.
2. Overridden Functions : 
~To call the overridden function of base class syntax used is :
   super.functionName(< argument >);
3. Normal Functions :
~To call other function syntax used is :
   functionName(< argument >);
~Classes should highly cohesive.

No comments:

Post a Comment

Chapter : 1 - First code in Node JS Previously I have written a blog about Getting Started with Node JS and its installation. Now lets s...