Skip to content
Sharp

Object-oriented programming · interview question

In an e-commerce application, which class should be responsible for validating a discount code?

Multiple choiceMediumchapter-3-curatedpremiumoopobject-responsibility
Choose one answer
Answer and explanation

Correct answer

C. DiscountValidator

Why

The DiscountValidator class should handle the validation of discount codes. This keeps the validation logic separate and focused, adhering to the single responsibility principle.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →