Search This Blog

17 June, 2011

Abstract data type

Abstract data type:-
Their is a big misconception related to abstract data type and Abstract class.
Both terms have a different meaning. Every class is a abstract data type, but every class is not a abstract class.


Under the meaning of abstract. Abstract means not concrete or rough.
Lets say that we create the following class.


class Employee
{
public int id;
public string name;
public void setId (int i)
{
id=i;
}
public void setName(String n)
{
name=n;
}
public int getId()
{
return id;
}
public string getName()
{
return name;
}
}


Note:- The above class is not an abstract class, its object can be created but the above class is a abstract data type.
When we read the above code we understand that their is some entity named as employee whose attributes are Id and name.
But it is not concrete that what is the Id and what is the name of the employee.
In these terms the data type is seen as not concrete because value based information does not exists hence the type is called an abstract data type. when its object is created and value will be assigned then it will get a concretef form.
At the data type level its abstract.
Abstract class means a class which cannot be put to a concrete form i.e. which cannot be instantiated because the body part of the process doesn't exist.
-----------------------------------------------------------------

No comments:

Post a Comment

Meetme@