Skip to content
Sharp

Core Java · interview question

When refactoring a procedural e-commerce script into an object-oriented design, what is a sign that a group of related functions should become a method in a new class?

Multiple choiceMediumchapter-2-curatedpremiumcore-javacode-reading-and-refactoring-to-objects
Choose one answer
Answer and explanation

Correct answer

A. They operate on the same set of data.

Why

When a group of functions operates on the same set of data, it indicates high cohesion, which is a key principle in object-oriented design. Consolidating them into a class method improves encapsulation and maintainability.

Test yourself on Core Java

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

Start free test
All Core Java questions →