Skip to content
Sharp

Object-oriented programming · interview question

Why might a developer choose to use a 'restock' method rather than a public setter for inventory?

Multiple choiceHardchapter-3-curatedpremiumoopcontrolled-mutation
Choose one answer
Answer and explanation

Correct answer

C. To apply business logic such as checking supplier availability

Why

A 'restock' method allows the developer to incorporate business logic, such as checking supplier availability, while updating inventory levels, which a simple setter would not support.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →