Skip to content
Sharp

Object-oriented programming · interview question

Why does Chapter 2 move from loose variables to classes like Product and CartItem?

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

Correct answer

C. Because related state and behavior become easier to model under one named concept

Why

Classes help group data and behavior that belong together. Instead of passing several unrelated values everywhere, the code can work with named concepts such as Product, Customer, and CartItem.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →