Skip to content
Sharp

Language Upgrades · interview question

How can sealed classes be used to enforce architectural constraints in a Java e-commerce application?

Multiple choiceHardchapter-12-curatedpremiumlanguage-upgradessealed-classes
Choose one answer
Answer and explanation

Correct answer

C. By allowing only certain payment methods to be subclassed.

Why

In an e-commerce application, sealed classes can enforce architectural constraints by restricting inheritance to specific, vetted classes. For example, only allowing certain payment methods to be subclassed ensures that only trusted and verified implementations are used.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →