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

can main method be overloaded...??? How..????

2 Answers   Satyam,


When is it necessary to use member-wise initialization list in C++?

2 Answers   Adobe,


When will a constructor executed?

5 Answers   TCS,


Why static functions always uses static variables?

3 Answers  


What is abstraction oop?

0 Answers  






What is a superclass in oop?

0 Answers  


Prepare me a program for the animation of train

0 Answers  


What is conditional Compilation?

3 Answers   emc2, HCL,


How is data security provided in Object Oriented languages? ?

5 Answers  


JAVA is FULLY OBJECT ORIENTED PROGRAMING LANGUAGE?

3 Answers  


why freind function takes more parameter than normal member function in c++?

1 Answers   IBM,


What is the correct syntax for inheritance? 1) class aclass : public superclass 2) class aclass inherit superclass 3) class aclass <-superclass

6 Answers   Wipro,


Categories