An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship?

An object that refers to part of itself within its own methods can use which of the following reserved words to denote this relationship?

a)       inner
b)       i
c)       private
d)       this
e)       static


Answer:  d.

Explanation:  The reserved word this is used so that an object can refer to itself.  For instance, if an object has an instance data x, then this.x refers to the object’s value x.  While this is not necessary, it can be useful if a local variable or parameter is named the same as an instance data.  The reserved word this is also used to refer to the class as a whole, for instance, if the class is going to implement an interface class rather than import an implementation of an interface class.


Enhancing Classes

Learn More Multiple Choice Question :