Skip to content
Sharp

Object-oriented programming · interview question

Which of the following best describes the benefit of moving behavior closer to data in object-oriented programming?

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

Correct answer

D. It enhances encapsulation and cohesion.

Why

By placing behavior in the same class as the data it manipulates, encapsulation and cohesion are improved. This makes it easier to maintain and understand the code since related functionality is grouped together.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →