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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can we make game by using c

3417


What are the 3 pillars of oop?

611


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1636


When not to use object oriented programming?

567


Why is encapsulation used?

577






What is the purpose of polymorphism?

675


What is static in oop?

585


What is overriding in oop?

548


program for insertion ,deletion,sorting in double link list

2276


Why do we need polymorphism in c#?

684


What is the point of polymorphism?

584


How many human genes are polymorphic?

570


What is encapsulation with real life example?

570


What is polymorphism what are the different types of polymorphism?

563


What are the benefits of oop?

604