What happens when you create an arraylist as ArrayList Arr=new ArrayList()

A) An arraylist of object Arr is created with the capacity of 16
B) An arraylist of object Arr is created with the capacity of 20
C) An arraylist of object Arr is created with the capacity of 26
Explanation: Default capacity is 16 if size is not specified

Showing Answers 1 - 10 of 10 Answers

Mike K

  • Mar 5th, 2006
 

The default initial capacity for an ArrayList is 0. Check C# Documentation

Leo

  • Mar 7th, 2006
 

The initial capacity is the starting capacity of the new ArrayList. The default initial capacity for an ArrayList is 16.http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsarraylistclassctortopic1.asp

  Was this answer useful?  Yes

rohit

  • Apr 24th, 2006
 

Answer A is correct. Once it will reach size 16 addding element in the arraylist, it will be automatically double the size.

  Was this answer useful?  Yes

nitin

  • Nov 16th, 2006
 

A is the  correct answer!!

  Was this answer useful?  Yes

Darain

  • Mar 19th, 2009
 

In .Net v1, default initial capacity of ArrayList is 16.
In .Net v2, default  initial capacity of ArrayList lowered to 4.
In .Net v3.5, default initial capacity of ArrayList lowered to 0.

Now, when you add the first element to a new arraylist it sets its first capacity to 4, and double the capacity whenever the Count exceeds the Capacity.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions