Skip to content
Sharp

Object-oriented programming · interview question

In the context of object-oriented programming, why should behavior be moved closer to the data it operates on?

Multiple choiceMediumchapter-2-curatedpremiumoopinstance-methods
Choose one answer
Answer and explanation

Correct answer

B. To increase cohesion and maintainability.

Why

Moving behavior closer to the data it operates on increases cohesion within a class, making the design more maintainable and allowing for easier updates and debugging.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →