Skip to content
Sharp

Core Java · interview question

When refactoring procedural code into an object-oriented design, what is a common indicator that a set of related functions and variables should become a class?

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

Correct answer

D. They operate on the same data structure or concept.

Why

When functions and variables operate on the same data structure or concept, they form a cohesive unit that can be encapsulated within a class. This refactoring improves maintainability and clarity.

Test yourself on Core Java

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

Start free test
All Core Java questions →