this vs. super keyword

What is the purpose of 'this' keyword?

- 'this' keyword is used to refer current instance of an object.

- It is a non-static method and cannot be used inside main method in Java.

- It is used to invoke current class constructor.

- It can be passed as an argument in the method call.

Significance of Super keyword.

- It is used to access the methods of a parent class.

- It is a non-static method and cannot be used inside main method in Java.

- It invokes the constructor of the parent class.

- The Outer.super can be used to get current instance of an outer class and its parent in Java.

Compare 'this' vs 'super' keyword.

'this' keyword'super' keyword
It represents the current instance of a class.It represents the current instance of a parent class.
It is used to call default constructor of the same class.It is used to call default constructor of the parent class.
It is used to access methods of the current class.It is used to access methods of the base class.
It is used for pointing the current class instance.It is used for pointing the super class instance.
What are JAR, WAR and EAR files?
What are JAR, WAR and EAR files? - JAR - Java Archive File is used to package classes and property files......
Significance of Classpath environment variables
Significance of Classpath environment variables - It is the list of directories which is used by JVM to find a class.....
What is a Garbage collector?
What is a Garbage collector? - Garbage collector cleans up objects which are no longer used. It is the thread running as part of JVM......
Post your comment