Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers | ||||
| ||||
Ans. 1. Methods can participate in runtime polymorphism whereas member variables cannot. For example - Vehicle vehicle = new Car(); car.getObjVariable();// will return variable defined in Car whereas car.variable will return the variable from Car class irrespective of the object it holds. 2. Validations can be performed before setting the variables. 3. If the input format changes or some other value or calculated value needs to be returned , that can be absorbed by making change ( wrapping ) in the setter and getter. By this the call to method from outside or interface to the object will remain the same. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   beans   getter   setter | ||||
Related Questions | ||||
How to generate getters and setters automatically in eclipse ? | ||||
Why it's a good practice to expose member elements through getter methods ? | ||||
What ate the getter and setter methods ? | ||||
Are getters setter / accessor mutator methods instance methods or static methods ? why ? | ||||