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

When not to use object oriented programming?

564


How does polymorphism work?

631


What is object in oops?

608


How many human genes are polymorphic?

566


What is inheritance in oop?

597






what are the different types of qualifier in java?

1836


Is oop better than procedural?

562


They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?

1403


Where is pseudocode used?

561


Why oops is important?

599


Why is oop useful?

595


What is the purpose of enum?

577


This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.

1633


What are the 4 pillars of oop?

664


What are main features of oop?

627