Skip to content
Sharp

Modern Java · interview question

Given a record 'Product' used in an e-commerce application, what is a potential drawback of directly exposing its components?

Multiple choiceHardchapter-7-curatedpremiummodern-javamodern-java-design-choices
Choose one answer
Answer and explanation

Correct answer

B. It may expose internal representations, leading to a tight coupling

Why

Directly exposing components can lead to tight coupling and expose internal details. This can make future changes more difficult, as clients of the record might rely on these details.

Test yourself on Modern Java

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

Start free test
All Modern Java questions →