Skip to content
Sharp

Object-oriented programming · interview question

Why does 'this' keyword in a constructor matter in practice?

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

Correct answer

A. To refer to the current object instance.

Why

In a constructor, 'this' is used to refer to the current object instance. It is commonly used to differentiate class fields from parameters with the same name.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →