Explain the concept of abstracion and encapsulation with
one example. What is the difference between them?

Answers were Sorted based on User's Feedback



Explain the concept of abstracion and encapsulation with one example. What is the difference betwe..

Answer / purba phalguni mishra, gandhi

ENCAPSULATION->
* It is a mechanism which unites the code and the data it
manipulates.

*It keeps them safe from external interference and misuse,
thus enforcing the separation between specification and
implementation of ADTs. Hence it enables the debugging of
program easily.

DATA ABSTRACTION->
* It is the creation of new data types [ADTs] using
encapsualted-items that are well suited to an application
to be programmed.

* It is a powerful technique resulting in optimal, more
readable and flexibles programs.


*******U r most welcome to challenge with my answer*****

Is This Answer Correct ?    9 Yes 2 No

Explain the concept of abstracion and encapsulation with one example. What is the difference betwe..

Answer / naveed

Abstraction refers to the act of representing essential
features without including the background details or
explanations.

Encapsulation is the procedure of covering up of data and
functions into a single unit (called class).

FOR EXAMPLES AND MORE INFO GOTO :

public class School
{
private string Schooldepartname;
public string SchoolDepartname
{
get
{
return Schooldepartname;
}
set
{
Schooldepartname =value;
}
}
}
public class Departmentmain
{
public static int Main(string[] args)
{
School d= new School();
d.SchoolDepartname="Communication";
Console.WriteLine("The Dept. Name is :
{0}",d.SchoolDepartname);
return 0;
}
}

From the above we can see the use of Encapsulation by using
properties. The property has two accessor get and set. The
get accessor returns the value of the some property field.
The set accessor sets the value of the some property field
with the contents of "value". Properties can be made read-
only. This is accomplished by having only a get accessor in
the property implementation.

Abstraction
Any function having lines of code we dont need the code of
function ie hiding detail but we know that what result we
are getting ie (showing essential )

Is This Answer Correct ?    1 Yes 0 No

Explain the concept of abstracion and encapsulation with one example. What is the difference betwe..

Answer / aarti ashar

(1)Abstraction:
To implement real world entity into program. Class uses the
concept of abstraction.
->abstraction is a process of mimicking a behavior.
->Simplifying complex reality by modeling classes
appropriate to problem.
->Abstraction is a process that involves identifying the
crucial behavior of an object and eliminating irrelevant
and tedious details.


(2)Encapsulation:
->Binding the data and code to access that data.
Encapsulation only refers to a container which has a data
and its related functions in it.
->When an objects state and behavior are kept together they
are encapsulated. The data and the methods that manipulated
that data are stored together in cohesive unit.

Is This Answer Correct ?    3 Yes 4 No

Post New Answer

More OOPS Interview Questions

How to use CMutex, CSemaphore in VC++ MFC

0 Answers   Persistent, TCS,


diff between Abstract class Interfaces?

4 Answers  


What is abstraction example?

0 Answers  


what are the ways in which a constructors can be called?

2 Answers   TCS,


What are the three main types of variables?

0 Answers  






i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<<k; } //please comment on the output

0 Answers  


what is the virtual function overhead, and what is it used for ? i hope i can get and appropriate answers, thanks a lot....

6 Answers  


write a program to print * * * * * *

2 Answers  


What is destructor in oop?

0 Answers  


WRITE A SIMPLE C++ PROGRAM TO SWAP TWO NOS WITHOUT USING TEMP

2 Answers  


why destructor is not over loaded?

5 Answers  


Can we have inheritance without polymorphism?

0 Answers  


Categories