Content deleted Content added
ClueBot NG (talk | contribs) m Reverting possible vandalism by 62.255.15.114 to version by Sameg14. False positive? Report it. Thanks, ClueBot NG. (2081162) (Bot) |
|||
Line 12:
== As information hiding mechanism ==
{{See also|Information hiding}}
Encapsulation in java is a process of wrapping code and data together into a single unit, for example capsule i.e. mixed of several medicines.
Encapsulation can be used to hide data member and member function.
Under this definition, encapsulation means that the internal representation of an [[object (computer science)|object]] is generally hidden from view outside of the object's definition. Typically, only the object's own methods can directly inspect or manipulate its fields. Some languages like [[Smalltalk]] and [[Ruby (programming language)|Ruby]] only allow access via object methods, but most others (e.g. [[C++]], [[C Sharp (programming language)|C#]] or [[Java (programming language)|Java]]) offer the programmer a degree of control over what is hidden, typically via keywords like <code>public</code> and <code>private</code>.<ref name=Pierce/> It should be noted that the ISO C++ standard refers to <code>protected</code>, <code>private</code> and <code>public</code> as "access specifiers" and that they do not "hide any information". Information hiding is accomplished by furnishing a compiled version of the source code that is interfaced via a header file.
|