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. Encapsulation and Polymorphism.|
We need methods to access variables in a polymorphic way as overriding only happens with methods and not with variables. Moreover getter provides a way to minimally open the access window for the object and hence provides better encapsulation. To add to those, we can have validation in the getter method before returning elements.
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  encapsulation|
|What is the difference between Encapsulation and Abstraction?|
|Can you give a real world example of Encapsulation and Abstraction ?|
| Which of the following Java feature promotes access protection or Hiding ?|
|What are the features of encapsulation ?|
|How is Abstraction implemented in Java ?|
|Difference between Encapsulation and Data Hiding ?|
|How can we hide a class in Java ?|
|Define encapsulation in Java ?|
|Which of the OOP's feature - encapsulation or abstraction - is more important ?|