Define Encapsulation?
Answers
Answer:
1) In object-oriented programming, encapsulation is the inclusion within a program object of all the resources need for the object to function - basically, the methods and the data. The object is said to "publish its interfaces." Other objects adhere to these interfaces to use the object without having to be concerned with how the object accomplishes it. The idea is "don't tell me how you do it; just do it." An object can be thought of as a self-contained atom. The object interface consists of public methods and instantiated data.
2) In telecommunication, encapsulation is the inclusion of one data structure within another structure so that the first data structure is hidden for the time being. For example, a TCP/IP-formatted data packet can be encapsulated within an ATM frame (another kind of transmitted data unit). Within the context of transmitting and receiving the ATM frame, the encapsulated packet is simply a stream of bits beween the ATM data that describes the transfer.
Encapsulation is one of the fundamentals of OOP (object-oriented programming). It refers to the bundling of data with the methods that operate on that data. Encapsulation is used to hide the values or state of a structured data object inside a class, preventing unauthorized parties' direct access to them.