Packaging an object?s variables within its methods is called encapsulation.
It is protective wrapper which prevents the data from being accessed by the code outside the the wrapper, the code inside the wrapper can be accessed by a well defined interface<br><br>ex: class is a protective wrapper which binds data and methods together,they can be accessed only though well defined interface(i.e object of that class)
The wrapping of data and function together in a single unit is called encapsulation. It tell how to bind data.this is useful to hide the data which is the new feature added to oops for providing security.
Encapsulation<br>1. Encapsulation is the mechanism that binds together code and the data it manipulates and keeps both safe from outside interference and misuse.<br>2. Encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.<br>3. It binds the data and codes that operates on the data into a single entity.<br>4. Encapsulation protects an implementation from unintended actions and inadvertent access.<br>5. The encapsulation of instance variables is sometimes called as ?Information Hiding?.<br><br>The technique of hiding the internal implementation detail of an object from it?s external views. Internal structure remains private and services can be accessed by other objects only through messages passed via a clearly defined interface. Encapsulation ensures that the object providing service can prevent other objects from manipulating its data or procedures directly, and it enables the object requesting service to ignore the details of how that service is provided.<br>
It is the ability of object to hide its data n methods from rest of the programe.It is one of the fundamental principles of OOPs.<br>for Ex let we have a class called Multiplication defined below<br>Public class Multiplication<br>{<br> private void Multiply(int x,int y)<br> {<br> return x*y<br> }<br>}<br>...<br>...<br>Multiplication abc;<br>int Result;<br>Result=abc.Multipy(2,5);<br>now Multiplication is a class having fumction Multiply as one of its function and abc is the object of the class and this class is used to access the multiply function n there is no other source to access the function multiply hence no one but only object have the power to access the member function of class hiding it from the out side world.
encapsulation is feature of oops concept it is nothing but class<br>class:-<br>wrapping up of both the data members and the member functions is called class which is extacted from the concept encapsulation
Encapsulation is used for data hiding. By using encapsulation, operations on datas can be performed through well defined interfaces. This ensures impossibility of inadvertent change of data. For example member values of an object can only be modified through its member methods. In C++, declaring a function friend of a class makes it feasible to access the class data. Java don't have any such concept and seems more objective in this sense.
Encapsulation is the mechanism that binds together the code and the data it manipulates and keeps both safe from outside interference and misuse.<br><br>It provides the explicit boundary between an object's abstract interface and it's internal implementation details.
Encapsulation is the method of putting all the similar data into a single block.Where this single block is nothing but the class.where it contains the attributes and methods.
process of binding the member variable of a class along with member functions. It can be implemented with the help of object and also access modifiers like private, public and protected.
Ex: let us take medicine capsule ,it protects with cover .if we open it,medicine gets reaction with oxyzen,nitrozen and etc, it becomes useless.....however data members and member functions should protect from the unauthorised access.
Encapsulation is like a human Brain that consist "Everything" but not show to others, So We can say that "The term which is Wrapped up & having many characteristics is known as ENCAPSULATION".
i.e if we take an common example with compare to our life Brain, Tablets, computers etc are the the example of ENCAPSULATION.
wrapping up of data and function into single unit. we can access the data only through the interface. example: "Pen", i can access the pen's ink through the pen tip . here pen tip is the interface....