What is the use of Getters and Setters method ?

Answer Posted / marshallsudhan

Before get into the answer, we gotta know something
prior...! "JavaBeans".
JavaBeans are java classes that have properties. For our
purpose, think of properties as private instance variables.
since they're private, the only way they can be accessed
from outside of their class is through 'methods'in the
class.
The methods that change a propertiy's value are called
setter methods, and the methods that retrieve a property's
value are called getter methods.

Is This Answer Correct ?    54 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we call the constructor of a class more than once for an object?

625


Why is string builder not thread safe?

589


What is the purpose of return statement?

625


What is appletviewer?

564


What is a protected void?

502






What is console based application in java?

538


What is linked hashset and its features?

543


Can we use switch statement with strings?

616


What is the difference between static and non-static variables in java programming?

517


What is an exception? difference between Checked and Unchecked exception in Java

552


What are assembly attributes?

539


What is final variable?

494


How can you share data between two thread in Java?

522


Why strings in java are called as immutable?

589


What do you mean by Hash Map and Hash Table?

596