veena bijur wrote:1.data memeber name and salary are declared as private
2. those can be accessed only within the class.
3.. to make it accessible to other class we go for setter() and getter()
Note, however, that in general it's not a good idea to just throw getters and setters on every member as a matter of course. In most objects other than DTOs and JavaBeans, you won't directly expose the member variables like that. Rather, you'll provide methods that implement behavior, and manipulate or expose some aspect or form of the members as part of that behavior.