answersLogoWhite

0


Best Answer

While many people cite private class members as being an example of information hiding (another term for data hiding) this is not strictly true. In C++, for instance, the use of the private keyword does not hide any information, it simply limits access to that information. After all, the fact something is inaccessible does not mean it is hidden. The private keyword simply means the information has been placed in a cage but only members of the class have access inside that cage; neither the cage nor the information are hidden in any way, shape or form. The same analogy is also true of many other languages. So when we speak of data or information hiding we simply mean limiting access to that information.



In some programming languages this is also referred to as encapsulation. However, in object-oriented programming, encapsulation has another meaning altogether: it is the means by which data and the methods that operate upon that data are combined into a self-contained entity, an object. Encapsulation in this sense typically incorporates data hiding, but it is the encapsulation itself that provides the means by which that data has limited access. However, encapsulation goes beyond mere data hiding in that it also provides an interface to some or all of the hidden data. This not only allows the data to be manipulated in a highly-controllable and robust manner, but also permits the underlying data storage mechanism as well as the methods that operate upon that data to be altered without affecting the object's existing consumers. In other words, the underlying implementations may change quite drastically, but their effects are limited to the class of object itself. If you think of an object as being a protective capsule that can be internally altered without affecting the outside world, the notion of encapsulation becomes that much clearer (it is no coincidence that the verb encapsulatederives from the French noun capsule).



User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between encapsulation and data hiding?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is encapsulation and data hiding in dbms?

ODBMS stands for object oriented database management system. Encapsulation in ODBMS can be defined as binding of data together.


How data hiding is achieved in java?

Data hiding in the java is achieved through the use of encapsulation.


What are the various elements of Object oriented programming?

Encapsulation, data hiding, inheritance and polymorphism.


Is it true that wrapping up of data of different types into a single unit is known as encapsulation?

Not quite. Encapsulation means to combine data and the methods that work upon that data into a single unit (an object), such that access to both the data and methods is restricted in a controlled manner. Data-hiding is fundamental to encapsulation.


What is different between inheritance and encapsulation?

wrapping up of data and function into a single unit is called encapsulation where polymorphism is the ability to take more than one form


What term in java is used to indicate that a class's internal state is hidden from its clients?

Encapsulation............Hiding the data from others


Why encapsulation does not implement information hiding in object orientation?

Encapsulation also implements data hiding in an object oriented programming design. By encapsulating various methods & data objects into a single class they can also be hidden from all the other classes. You can declare the variables and methods as private and that way you can hide the data from the other classes in the application.


What is the difference between data abstraction and encapsulation?

Data Encapsulation : It is a process of bundling the data, and the functions that use them, as a single unit( atleast in C++) . In C++ the data type "class" is used to achieve this. Data Abstraction : It is a process of exposing only the interfaces and hiding the implementation details from the user. The interface exposed will remain the same: even if the internal implementation changes. This helps the user to use the new functionality without rewriting the client that was designed for previous implementation (strictly speaking ... previous interface).


What are the main features of OOP in c plus plus?

The main features of OOP are the same regardless of the language. They are: encapsulation; data hiding; inheritance; and polymorphism.


What is the difference between structure and class?

Structures are public by default while classes are private by default. Classes are generally more beneficial as the encapsulation dictates the object's purpose, and data hiding ensures the data remains valid. But the ability to emit a structure from an object and vice versa simply adds to the overall flexibility, giving you the best of both worlds whenever needed.


Why is encapsulation called wrapping?

Encapsulation is also known as wrapping because it wraps the data in the same way as a toffee is wrapped to create a logical insulation between the data(program) & the outer world(computer).


What does it mean by encapsulation?

Encapsulation makes class fields private, preventing access to it from outside of the class. Essentially, this data is hidden from the rest of the program. It is possible to allow access to the fields via public methods.