Skip to content
Sharp

Object-oriented programming · interview question

In an e-commerce application, which of the following fields in a Product class is least likely to need a setter?

Multiple choiceEasychapter-3-curatedpremiumoopgetters-and-setters-design
Choose one answer
Answer and explanation

Correct answer

D. ProductId

Why

The productId is typically a unique identifier that should not change once assigned, so it doesn't need a setter.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →