191k views
0 votes
What is the 'this' keyword and its relation to instance methods?

a) It refers to the current instance of the class and is used to access instance variables and methods
b) It refers to the parent class in inheritance
c) It's used for conditional statements in methods
d) It's a reserved keyword for defining interfaces

1 Answer

4 votes

Final answer:

The 'this' keyword in Java refers to the current instance of the class and is used to access instance variables and methods.

Step-by-step explanation:

The 'this' keyword in Java refers to the current instance of the class and is used to access instance variables and methods. It allows us to differentiate between local variables and instance variables with the same name. The 'this' keyword is typically used within instance methods, which are methods that belong to a specific instance of a class.

User Csharpbd
by
8.3k points