difference between abstraction and encapsulation with progarammatic eg.
hi,just recently i went for an interview .The interviewer asked what is the difference between abstraction and encapsulation with programmatic eg.
I gave the answer as
encapsulation mean hiding the relevant data which is not useful for the user, eg a electric fan .hiding the information how the electricity is converted into machanical energy.
abtraction showing only the relevant data to the user eg electric fan.
it look ,its color ,it design etc only relevant data.
Then the interviewer asked me, give me some programmic eg .I Said
Let assume a web form having control like textbox,button etc.
The user can view textbox,button etc this is the eg of abstraction
and when the user click on the button how he is redirected is not known by the user is the eg of the encapsulation.
Am I Correct .was the answer given by me is perfect .now i am planing to go for an another interview should i give the same answer.IF not please suggest me a better answer.with some good eg Please help

Answer Posted / sachinmundhra

Your approach is correct. Encapsulation is data hiding and
abstraction is a mechanism acheived by encapsulation.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What makes a language oop?

604


can inline function declare in private part of class?

3668


Can static class have constructor?

595


what is the drawback of classical methods in oops?

2926


Is react oop?

618






Why polymorphism is used in oops?

594


Write a java applet that computes and displays the squares of values between 25 and 1 inclusive and displays them in a TextArea box

2044


What are the 4 main oop principles?

695


What is abstraction and encapsulation?

583


Can we define a class within the interface?

567


What is constructor in oop?

593


What is encapsulation c#?

613


What is polymorphism and its types?

609


What is basic concept of oop?

714


write string class as your own class in java without using any built-in function

1984