Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
Accessor methods, also known as getter methods, are a type of method in object-oriented programming that allows the retrieval of the value of an object's private data member. They provide read-only access to the internal state of an object.
Related terms
Getter Methods: Getter methods are a specific type of accessor method that retrieves the value of a specific attribute or property of an object.
Encapsulation is a principle in OOP that combines data and functions into a single unit called an object, where data is hidden from external access and can only be accessed through defined public interfaces (such as accessor and mutator methods).