Java Keywords Interview Question 2
Why do we use 'this' keyword in java?
The keyword ‘this’ can be used:
To refer to current class instance variable
To refer to current class method
To refer to current class constructor
To learn more about this keyword, examples, etc click here to visit this section of our java tutorial
Why do we use 'super' keyword in java?
Super keyword in java is used to call:
Immediate super-class instance variables
Immediate super-class methods
Immediate super-class constructors
To learn more about super keyword and examples, click here to visit super section of our java tutorial.
Can 'this' and 'super' both be used with constructor?
To be updated soon...
Can 'this' be used in static context?
No, this keyword cannot be used in static context.
Can 'super' be used in static context?
No, super keyword cannot be used in static context.