Super Keyword in JAVA
Super Keyword is a reference variable name that refers to the parent class object. Super means parent class.
class A { int a=40; } class B extends A { int a=20; void show(int a) { System.out.println(a); // output will be 30 System.out.println(super.a); // output will be 40 System.out.println(this.a); // output will be 20 } public static void main(String[] args) { B b = new B(); b.show(30); } }
This keyword : current class instance variable
Super keyword : parent class instance variable