• 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic