Sunday, 31 January 2016

Super keyword in java

Super keyword in java

Hello friends, Hitesh is here; Today we will learn some basic point related to Super keyword in java

First we know about definition of super keyword in java

Definition:

Super keyword in java is a reference variable that is used to refer immediate parent class object.

Note: One point always remember about super keyword is; super() is added in each class constructor automatically by compiler and it is must be first statement.
super keyword in java

Uses of Super Keyword

  1. super.<variable_name> refers to the variable of variable of parent class.
  2. super() invokes the constructor of immediate parent class.
  3. super.<method_name> refers to the method of parent class.

Difference between Super and This keyword

this keyword used to store current object reference and super keyword used to store super class reference in subclass object.

For complete tutorial you can visit our own website. Thanks

No comments:

Post a Comment