Skip to content
Sharp

Object-oriented programming · interview question

How can 'this' be used to resolve a naming conflict between a method parameter and an instance field?

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

Correct answer

C. By prefixing the field with 'this'.

Why

'this' can be used to prefix the field name to resolve naming conflicts between parameters and instance fields, ensuring the field is accessed.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →