• Post Reply Bookmark Topic Watch Topic
  • New Topic

Map  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. Which of the following allows duplicates, and introduces positional indexing.?
[a] Set
[b] Map
[c] Iterator
[d] List
Answer 2
[b] Map
I think the ans is wrong, because May cnt contain duplicates. however, which is right ans?
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a List to me.
From API:
An ordered collection (also known as a sequence). The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list.
Unlike sets, lists typically allow duplicate elements.

[This message has been edited by Jim Hall (edited December 15, 2001).]
 
Ranch Hand
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
answer is B)Map.
no duplicates of the Keys only. You can have duplicates values.
but not sure whats the meaning of positional indexing.
 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't be a Map. There is no concept of positional indexing in a Map. The Map only provides a get(Object key) method for accessing its elements.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I would choose answer d, because Lists allow duplicate entries and maintain their elements in a specified order. All elements in a List get an unique index, which can be used to access them ( http://java.sun.com/j2se/1.4/docs/api/java/util/List.html#get(int) ). I think that's what 'positional indexing' refers to.
/JT
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!