This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Encapsulation

 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friends,

plz send a good definition for encapsulation.
 
michelle anderson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Encapsulation is a technique for hiding data and behavior within a class;it helps you write clean, modular software.

Hope this helps.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In practice, encapsulation basically means making variables private and allowing them to be accessed and/or manipulated only through methods.

This is particularly useful where polymorphism is concerned. See thread http://www.coderanch.com/t/246221/java-programmer-SCJP/certification/Good-you-figure-it-out
[ September 13, 2004: Message edited by: marc weber ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Information hiding" is a concept that I Googled once and found references back into the 1970s. It's key to good modularity in procedural or OO languages. A C module can hide its algorithms, but an object can also hide and protect its data so thoroughly that no external chunk of code can mess it up. Encapsulation is "improved information hiding." (Not meant to be a closed definition ... does it mean more to you?)
 
Sham Grandhe
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you friends this will help me a lot.

with regards
shyam.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!