Posts

Showing posts with the label super Keyword in Java

Super Keyword in Java or program to demonstrate usage of super keyword. rcub

  Super Keyword in Java The  super  keyword in Java is a reference variable which is used to refer immediate parent class object. Usage of Java super Keyword -->super can be used to refer immediate parent class instance variable. --> super can be used to invoke immediate parent class method. --> super() can be used to invoke immediate parent class constructor. 1.super can be used to access Base class Variables. Syntax: super.<instance variable>; Example: class A {       int a; } class B extends A {          B(int x)        {            super.a=x;          }      void display()     {      System.out.println("A value="+super.a);    }   public static void main(String args[])   { ...