Hi,
Apart from using modifiers how can we implement encapsulation?
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Mahesh ChandRank #1 · 393.3K reputationPosted Mar 28, 2011, 5:33 PM EDT
Kavita B135 reputationPosted Mar 28, 2011, 5:49 PM EDT
Are interfaces also used for the same?
VulpesRank #55 · 29.2K reputationPosted Mar 29, 2011, 12:58 AM EDT
However, as I intimated in your thread about private classes, when members of an interface are implemented explicitly this does achieve a level of encapsulation (in the 'hiding functionality' sense). This is because the method isn't marked ''public' and the caller therefore needs to be aware that you need an interface reference (not a reference to an object of the class itself) to call the method.
In contrast properties normally achieve encapsulation by hiding data (i.e. their backing fields).
Kavita B135 reputationPosted Mar 29, 2011, 3:35 AM EDT
Thanks for replying..Can encapsulation be implemented in any other way apart from what as been discussed till now???
VulpesRank #55 · 29.2K reputationPosted Mar 29, 2011, 3:46 AM EDT
Kavita B135 reputationPosted Mar 29, 2011, 5:45 PM EDT
Thanks a lot,i`m just a beginner need to know many things,sometimes my questions may not be clear so please don`t mind...