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

What are the four main oops concepts?

1 Answers  


Why we are use # in begning of programme of c++.

2 Answers   Syntel,


What is variable example?

0 Answers  


Is html an oop?

0 Answers  


polymorphism means?

6 Answers   BFL,






A file pointer always contains the __________ of the file

5 Answers  


What is the real time example of inheritance?

0 Answers  


What is a class oop?

0 Answers  


What is coupling in oop?

0 Answers  


what is virtual function in c++

6 Answers  


What is difference between polymorphism and inheritance?

0 Answers  


What is multiple inheritance? Give Example

6 Answers   Mind Tree,


Categories