Skip to content
Sharp

Object-oriented programming · interview question

Why can exposing a public getter for a 'password' field in a User class become a problem in production code?

Multiple choiceMediumchapter-3-curatedpremiumoopgetters-and-setters-design
Choose one answer
Answer and explanation

Correct answer

D. It violates data privacy principles.

Why

Exposing a public getter for sensitive data like a password can lead to security vulnerabilities, as it allows external code to retrieve the password, violating privacy and security principles.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →