Skip to content
Sharp

Object-oriented programming · interview question

Given the constructor public Order(String id, List<Item> items), what is a potential flaw in this design?

Multiple choiceHardchapter-2-curatedpremiumoopconstructors
Choose one answer
Answer and explanation

Correct answer

A. The constructor does not validate the items list

Why

A potential flaw is that the constructor does not validate the items list, which could lead to issues if null or an empty list is passed, affecting order processing.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →