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.
|Java - 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
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|
|How to generate getters and setters automatically in eclipse ?|
|What ate the getter and setter methods ?|
|Why it's a good practice to expose member elements through getter methods ?|
|Are getters setter / accessor mutator methods instance methods or static methods ? why ?|