Super Keyword The super keyword in java is a reference varible which is use to refer immediate parent class instance variable . Super can use to invoke immediate parent class method and constructors also. 1. To Refer Instance variable of an immediate parent class: We can use super keyword to access the data member or field of parent class. It is used if parent class and child class have same fields. For example, class Animal{ String color="white"; } class Dog extends Animal{ String color="black"; void printColor(){ System.out.println(color); System.out.println(super.color); } } class TestSuper1{ public static void main(String args[]){ Dog d=new Dog(); d.printColor(); } } Output: black white 2. To Refer method of an immediate parent class: The super keyword can also be used to invoke parent class method. It should be used if subclass contains the same method as parent class. In other words, it is used if method is overri
A blog about Java basic concept, Java Keywords, Algorithems, Loops, Conditional loops, Data Structure, Java collections, Database, OOPS concepts, Java Interface, Java String, Java Execption handling, Java Networking, Java AWT, Java Swing, Java Applet, Java JDBC, Java Multithreading, Java I/O, Java String, Java conversion, Java date. And we are going to explain every point in deep for better understanding.