Skip to content
Sharp

Object-oriented programming · interview question

Why do teams use getter methods in a class in production code?

Multiple choiceEasychapter-2-curatedpremiumoopobject-interaction
Choose one answer
Answer and explanation

Correct answer

A. Encapsulation and controlled access to fields.

Why

Getter methods provide controlled access to private fields, maintaining encapsulation by allowing fields to be read without exposing them directly.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →