Define Accessor method

Accessor method: A technique specifically designed to offer access to a private attribute of a class. By convention, we name accessors with a get prefix followed by the name of the attribute being accessed. For example, the accessor for an attribute named speed would be ‘getSpeed’. By creating an attribute private, we save objects of other classes from varying its value other than via a mutator method. The Accessors are employed both to grant safe access to the value of a private attribute and to save attributes from inspection by the objects of other classes. The later goal is attained by selecting a suitable visibility for the accessor.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.