Java Programming - Objects and Collections - Discussion

Discussion Forum : Objects and Collections - Pointing out the correct statements (Q.No. 8)
8.
Which statement is true for the class java.util.ArrayList?
The elements in the collection are ordered.
The collection is guaranteed to be immutable.
The elements in the collection are guaranteed to be unique.
The elements in the collection are accessed using a unique key.
Answer: Option
Explanation:

Yes, always the elements in the collection are ordered.

Discussion:
13 comments Page 2 of 2.

Radistao said:   10 years ago
Sorry, but this is a trap question related not to Java/programming knowledge, but definitions knowledge, like "ordered" != "sorted", but most of developers use "order" and "sort" as synonyms, so you confuse people. To be more consistent you should to fix A choice "The elements in the collection are ordered by insertion order".

In same time, D also looks correct! Because every element is accessed by unique key, which is an integer index of element!
(5)

AAKASH KUMAR said:   9 years ago
How can be an element in the order of ArrayList?

Prakash VL said:   9 years ago
Wrong Answer!

ArrayList elements are indexed. :)


Post your comments here:

Your comments will be displayed after verification.