This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes can we achieve data hiding withe the help of encapsulation... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "can we achieve data hiding withe the help of encapsulation..." Watch "can we achieve data hiding withe the help of encapsulation..." New topic
Author

can we achieve data hiding withe the help of encapsulation...

rahul S Sharma
Greenhorn

Joined: Jun 08, 2011
Posts: 21
Hi All,

Can we say that we can achieve data hiding with the help of encapsulation...?? please correct me if I am wrong....
regards....
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

yes, you can hide your own implementation from world.
rahul S Sharma
Greenhorn

Joined: Jun 08, 2011
Posts: 21
But i have read at so many places that encapsulation and information hiding are two different things. According to my understanding,
encapsulation is the mechanism that binds together code an data it manipulates.
Information hiding is hiding the data by using access specifiers like private, protected or default, so how can we relate encapsulation and information hiding.
I am very much confuse in these concepts. Please help me to make clear understanding of these concepts.
thanks in advance
chen logos
Greenhorn

Joined: Jun 16, 2011
Posts: 1
public :any class in any package can access;
privatenly members in the same class can access directly;
protected: subclass or class in the same package can access directly.
rahul S Sharma
Greenhorn

Joined: Jun 08, 2011
Posts: 21
Mr. Chen,
Welcome to ranch, i appreciate your words that you have written but i don't think this is the answer of my question...
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3065
    
    1

Encapsulation and data hiding in Java are the same thing.
rahul S Sharma
Greenhorn

Joined: Jun 08, 2011
Posts: 21
Mr. Stephan,
Could you please tell me how?
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3065
    
    1

What do you mean how? They are two different terms that refer to the same thing: Restricting the visibility of members so that they are only used by the classes responsible for them.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: can we achieve data hiding withe the help of encapsulation...
 
Similar Threads
What is encapsulation
OOPS Concepts - Redefined(Confirmation required)
BJO - information hiding v/s encapsulation
Encapsulation vs Data/information hiding
DataHiding and Encapsulation??