Skip to content
Sharp

Object-oriented programming · interview question

Given a 'Customer' class with a 'name' field, which method would be most appropriate to include?

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

Correct answer

A. GetName()

Why

A 'getName()' method is appropriate as it provides a way to access the 'name' field of a 'Customer' object. Methods should align with the class's responsibilities.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →