Java - Interview Questions and Answers on "this" Keyword

Q1.  What are the common uses of "this" keyword in java ?

Ans. "this" keyword is a reference to the current object and can be used for following -

1. Passing itself to another method.
2. Referring to the instance variable when local variable has the same name.
3. Calling another constructor in constructor chaining.

Q2.  What is "this" keyword used for ?

Ans. Used to represent an instance of the class in which it appears.

Q3.  Difference Between this() and super() ?

Ans. 

1.this is a reference to the current object in which this keyword is used whereas super is a reference used to access members specific to the parent Class. 

2.this is primarily used for accessing member variables if local variables have same name, for constructor chaining and for passing itself to some method whereas super is primarily used to initialize base class members within derived class constructor. 

Q4.  Can we use "this" within static method ? Why ?

Ans. No. Even though "this" would mean a reference to current object id the method gets called using object reference but "this" would mean an ambiguity if the same static method gets called using Class name.