difference between encapsulation and abstraction

1 view
Skip to first unread message

Arvind Chandok

unread,
Sep 20, 2007, 9:05:54 AM9/20/07
to technical-...@googlegroups.com

Hi all,

Can anybody explain difference between encapsulation and abstraction .
There is confusion both points to almost same concept.


Regards
--
Arvind Chandok
Contact : 9899825712,9896726880

Kuldeep1 S

unread,
Sep 21, 2007, 1:51:04 AM9/21/07
to technical-...@googlegroups.com, Superb Java

Abstraction is closely related to Encapsulation.

Abstracttion is a high level term. Its something like virtually practical. For example, Person.  Person is a abstract term. If I ask you who is person then you will say "Me,you and any other".  But what are Me, you and others, these are just real Objects which are termed as Person.  What I can say is that  theoretical description of any object is Abstraction. When you talk abt Abstraction we talk about "What" not "How". You do not need to be worry abt the details and complexity but need to represent it in a simple , easy and understandable. .

Encapsulation is more related to the implemenation. That is "How" . When you provide interfacing then you are telling the outer world that I will provide you this interface you just use it and do not bother about the internals.  It says I will hide the data/implementation from you. If I change anything internall in my implemenation it will not affect you. I have given you interface that will remain same. One more intersting thing I read from somwhere which says that Encapsulation is to keep the information private not secret. What you do in the bathroom is not secret but private.  

So my conclusion is that Abstraction is virtual and Encasulation is practical. What vs How.

Class name is  abstraction
Class interface(published/exposed portion) is Encapsulation

I am not sure whether you are satisfied by it or not..

Please recitify me whereever I am wrong or left any thing.




Regards,

Kuldeep Singh
Tata Consultancy Services
Plot No. 362-363,
Phase-IV,
Udyog Vihar,
Gurgaon - 122016,Haryana
India
Cell:- +919873722636
Mailto: kulde...@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty.        IT Services
                       Business Solutions
                       Outsourcing
____________________________________________



"Arvind Chandok" <arvind....@gmail.com>
Sent by: technical-...@googlegroups.com

09/20/2007 06:35 PM


To
technical-...@googlegroups.com
cc
Subject
[Discussion 91] difference between encapsulation and abstraction


ForwardSourceID:NT00004D7A    
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


Arvind Chandok

unread,
Sep 21, 2007, 2:16:12 AM9/21/07
to technical-...@googlegroups.com
Thanks Kuldeep.

It is a nice description to for Abstraction and Encapsulation.

Praveen Singh

unread,
Sep 21, 2007, 3:23:25 AM9/21/07
to technical-...@googlegroups.com
HI KULDEEP,

ITS REALLY NICE DESCRIPTION ABOUT ABSTRACTION AND ENCAPSULATION . CAN YOU GIVE US A CODDING EXAMPLE SO THAT SCENARIO WILL BE MORE CLEAR .

THANKS
PRAVEEN SINGH

Rajnish Kamboj

unread,
Sep 24, 2007, 1:00:50 AM9/24/07
to technical-...@googlegroups.com
Hello

As told by Kuldeep sir "Encapsulation is to keep the information private not secret."
I have a little bit of confusion here...

If " Encapsulation" is keeping things private than what is "Data Hiding"

In my opinion in broad terms
" Encapsulation" is keeping related entities under one hood
{in java those may be private, public or protected or default etc}
and if we keep those entities private to the rest of then world then we call it " Data Hiding"

or we can say
"Data Hiding" is the sub set of "Encapsulation" which further is asub set of "Abstraction"


Please correct me if i am wrong.. the above are my conclusions...
--
Rajnish kamboj
Mob: +91-9899401145

[ Smile a lot, it costs nothing :) ]
Reply all
Reply to author
Forward
0 new messages