this keyword

Q.  The keyword 'this' is used
- Published on 19 Oct 15

a. As reference to current object
b. Explicit constructor invocation
c. In open recursion
d. All the above

ANSWER: All the above
 
In object oriented programming the keyword 'this' is used to refer to objects, classes or any other entity that is part of currently running code. Different languages use it in different ways.

In some languages, 'this' is the only way to access data and methods in current object. The concept, however, is similar in all languages using 'this'.It is usually a fixed reference or pointer which refers to current object. In some languages it is used explicitly while others use lexical scoping( range of functionality) to use it implicitly to make symbols within their class visible. The dispatch semantics of 'this' that method calls on 'this'are dynamically dispatched which means that these methods can be overriden by derived classes or objects.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)