Skip to content
Sharp

Object-oriented programming · interview question

Why is it recommended to group related fields and methods in a class?

Multiple choiceMediumchapter-2-curatedpremiumoopclasses-and-objects
Choose one answer
Answer and explanation

Correct answer

B. To maintain encapsulation and modularity

Why

Grouping related fields and methods within a class helps maintain encapsulation and modularity, making the code more organized, reusable, and easier to maintain.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →