Skip to content
Sharp

Object-oriented programming · interview question

In a Java class 'Order', which constructor signature is most appropriate for initializing an order with a list of items and a customer?

Multiple choiceHardchapter-2-curatedpremiumoopbasic-modeling
Choose one answer
Answer and explanation

Correct answer

C. Order(List<Item> items, Customer customer)

Why

Passing a List<Item> and Customer object directly to the constructor allows the Order class to have a clear and direct relationship with its items and the customer, promoting object-oriented practices.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →