Skip to content
Sharp

Object-oriented programming · interview question

What should a developer consider when adding a method to update object state?

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

Correct answer

B. Ensuring it maintains class invariants

Why

When adding methods to update an object's state, it's crucial to ensure that the method maintains the class's invariants and does not leave the object in an invalid state.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →