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

to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 123

2 Answers  


What is advantage of inheritance?

0 Answers  


what is the technical or oop name of object?

1 Answers  


what is data abstraction with example.

1 Answers  


What is function overloading?,describe it with the example.

5 Answers  






what is function overloading..?

4 Answers  


What is overriding in oops?

0 Answers  


What is oops and its features?

0 Answers  


What is the concept of object oriented program?

6 Answers  


what is an qt4 interface?

1 Answers   IBM,


WHEN A COPY CONSTER IS CALL ?

4 Answers  


c++ provides classes...and classes do what we want but why then strcut are used...if we say data hiding... it is also provided by c++ in structs then why to prefer clasess

1 Answers   HCL, TCS,


Categories