8.07.2012

DOTNET Programming Concepts Difference FAQs-1

1.Difference between hash table and arraylist

S.No
Arraylist
Hash table
1
Array List is a List
Hash Table is a map
2
Here, we can only add items to the list
Here, we can add data with the key
3
Retrieving data using Arraylist is slower than Hashtable because If we want to find something in a arraylist we have to go through each value in arraylist.
Retrieving by key in Hashtable is faster than retrieving in Arraylist because If we want to find something in a hashtable we dont have to go through each value in hashtable, instead search for key values and is faster.

2.Difference between Hash Table and Arrays


S.No
Hash Table
Array
1
Hash table stores data as name,value pair.
Array stores only value
2
To access value from hash table, we need to pass name.
In array, to access value , we need to pass index number.
3
We can store different type of data in hash table, say int,string etc.
In array ,we can store only similar
type of data.

3.Difference between Dictionary and Hashtable


S.No
Dictionary
Hashtable
1
Dictionary is a generic type
Hashtable is not generic type.
2
In Dictionary we need to specify the types of both the key and the corresponding value.The value represents the actual object stored and the key represents a means to identify a particular object.
Hashtable is a collection of name/value pairs that are organised on the basis of hash code of the key being specified.
3
In Dictionary public static members are type safe but any instance members are not type safe.
Hashtable is thread safe for use by multiple reader threads and a single writing thread.
4
We cannot use Dictionary with Web Services The reason is no web service standard supports generic standard.
We can use Hashtable withWeb Services
5
Dictionary is aster than Hashtable because boxing is not required.
It is slower than dictionary because to retrieve a value we must cast it as its actual type, because it will be returned via object reference.

4.Difference between array and stack


S.No
Array
Stack
1
An array can be multi-dimensional
Stack is strictly one-dimensional
2
An array allows direct access to any of its elements
With a stack, only the 'top' element is directly accessible; to access other elements of a stack, we must go through them in order, until we get to the one we want

5.Difference between Stack and Heap


S.No
Stack
Heap
1
Memory will be allocated at the compile time.
Memory will be allocated at the run time.
2
Here the memory is allocated by the compiler.
Here the memory is allocated by the user.
3
Memory will be allocated only in sequential locations.
Memory will be allocated in sequential locations and non- sequential locations.
4
The memory will also be deleted by the compiler.
The memory must be deleted explicitly by the user.
5
There is lot of chance of memory wastage.
There is no chance of memory wastage if the memory is handled perfectly.

6.Difference between Array and ArrayList


S.No
Array
ArrayList
1
They are fixed length.
They are resizable and variable length
2
They are compiled strong type collection.
They are flexible and can accommodate any data types.
3
Because arrays are of fixed size and strong type collection performance is faster.
In arraylist lots of boxing and unboxing are done there for its performance is slower.
4
Array is in the System namespace
ArrayList is in the System.Collections namespace.
5
Ex:Char[] vowel=new Char[];
Ex:ArrayList a_list=new ArrayList();

No comments:

Post a Comment