What is the difference between the Encapsulation and
Abstraction

Answer Posted / amrut

Encapsulation is nothing but showing only those things
which are required by wrapping up complexity & hence it is
also called that it leads to data hiding but its not data
hiding. Never say its data hiding… its wrapping up
complexity in one capsule that is class & hence
Encapsulation…
While abstraction denotes the essential characteristics of
an object which differentiates from other kinds of object...

Abstraction is achieved by making class abstract having one
or more methods abstract. Which is nothing but essential
characteristic which should be implemented by the class
extending it.
e.g. when you inventing/designing a car you define a
characteristics like car should have 4 doors, break,
steering wheel etc… so anyone uses this design should
include this characteristics. Implementation is not the
head each of abstraction. It will just define
characteristics which should be included.

Encapsulation is achieved keeping data and the behaviour in
one capsule that is class & by making use of access
modifiers like public, private, protected along with
inheritance, aggregation or composition. So you only show
only required things, that too, only to the extent you want
to show. i.e. public, protected, friendly & private...
e.g. GM decides to use the abstracted design of car above.
But they have various products having the same
characteristics & doing almost same functionality. So they
write a class which extends the above abstract class. It
says how gear box should work, how break should work, how
steering wheel should work. Then all the products just use
this common functionality. They need not know how the gear
box works or break works or steering wheal works.
Indivisual product can surely have more features like a/c
or auto lock etc…..

Is This Answer Correct ?    17 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to repaint when working with horizontal scroll bar

1549


List out the basic features of MFC.

13707


What is mfc class hierarchy?

623


How to handle dynamic menus in mfc? What happens when client calls cocreateinstance?

698


How do I create a dialog box in mfc?

613






2.create for 10 batch: Employee_Number Employee_name Employee_Dateofjoining Employee_address Employee_salary 1.select the employee name who deriving more than 10 thousand salary and joined before august 08. use structure and pointers

1811


plzz tell me what we can do and dont in tally ERP & sap business one?

1882


What is the difference between Struts and JSF? Pls list some most suitable differences.

2847


what is functioning of DIalodDataXchange ..?

1196


what is the meaning of constant FILE EXCEEDS LENGTH LIMIT while loading from ps file to vsam in the jcl?

3346


I want recent paper pattern for HP company?

1791


Do you have an idea about MFC?

920


What does mfc stand for?

961


what message is sent to an application when the user presses the primary button?

1388