This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can we say that we can achieve data hiding with the help of encapsulation...?? please correct me if I am wrong....
regards....
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, you can hide your own implementation from world.
 
rahul S Sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Saloon Keeper
Posts: 8473
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encapsulation and data hiding in Java are the same thing.
 
rahul S Sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr. Stephan,
Could you please tell me how?
 
Stephan van Hulst
Saloon Keeper
Posts: 8473
155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!