Skip to content
Sharp

Object-oriented programming · interview question

How does 'this' help when field names and parameter names are the same?

Multiple choiceEasychapter-2-curatedpremiumoopthis-keyword
Choose one answer
Answer and explanation

Correct answer

D. It differentiates the field from the parameter.

Why

'this' is used to distinguish between a field and a parameter when they have the same name. It clarifies that you are referring to the field of the current object.

Test yourself on Object-oriented programming

A free test with instant, explained results. No account needed.

Start free test
All Object-oriented programming questions →