209k views
3 votes
An ArrayList object has a _____ property that stores its size. The initial value of the property is 16.

1) length
2) size
3)ount
4) capacity

User CIAvash
by
7.6k points

1 Answer

6 votes

Final answer:

An ArrayList in Java has a capacity property, but its initial value is typically 10 and not 16. The size of an ArrayList is obtained through the size() method, not a property.

Step-by-step explanation:

An ArrayList object in Java has a capacity property that stores the maximum number of elements it can hold without resizing. The initial value of the capacity is not specified to be 16; it is actually implementation-specific, but the default initial capacity of an ArrayList provided by the Java Collections Framework is 10. The option that incorrect refers to the 'capacity' aspect of an ArrayList, not its 'size'. The size of an ArrayList is the number of elements it currently holds, and it has a size() method to retrieve this value, not a property. No option provided in the question correctly describes a property that stores its size because ArrayList uses a method for this purpose.

User Mikael Weiss
by
8.2k points