Question:
Explain the Encapsulation principle.
Answer:
Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper. Source: CoolInterview.com
Encapsulation is the ability to hide implementation details by making class members(instance variables & methods) private or protected. So that you can make changes in your implementation code without breaking the code of others who use your code is a key benefit of encapsulation. Source: CoolInterview.com
Answered by: Nandkishor Gawali | Date: 4/19/2010
| Contact Nandkishor Gawali
Encapsulation is one mechanism that enables the java developer to combine the data(can be attributes of an object),and actions (methods or behaviors) that perform on the data. here whosoever uses the class may be able to access the data but not able to modify it. Encapsulation is such a mechanism which hides the original implementation that the user may not be able to modify it. Source: CoolInterview.com
Answered by: Ravi.B | Date: 4/23/2010
| Contact Ravi.B
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|