Skip to content
Sharp

Object-oriented programming · interview question

Why does a getter method in a well-encapsulated class matter in this design?

Multiple choiceEasychapter-3-curatedpremiumoopencapsulation
Choose one answer
Answer and explanation

Correct answer

A. To provide controlled access to a field's value

Why

Getter methods provide controlled access to a field's value, allowing external code to read the field without directly accessing it, thus maintaining encapsulation.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →