• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Collection

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Which of these statements concerning Map are true ?
a. It is permisible for a map to contain itself as a key.
b. values() method return an instance of Set.
c. The Map interface extends the collection interface.
d. All keys in a map are unique.
e. All map implementations keep the keys sorted.
I know that "c" is false.
a. false. It is permisible for a map to contain itself as a value & not as a map
But I am confused about the other options.
the values() method in Map returns a Collection, so does that make "b" true???
And does All map implementations keep the keys sorted.???
Thx in advance
Aruna
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! Aurna
First I would like to address point b. of your question.
The option b is not true. I looked up the tutorial on maps in java.sun.docs and I quote :
" values(): The Collection of values contained in the Map. This Collection is not a Set, as multiple keys can map to the same value. "
Second - point d.
All keys in a map are unique - true. Again from java.sun.docs.
"A map cannot contain duplicate keys: Each key can map to at most one value. "
Third - point e.
All map implementations keep the keys sorted - false
Only sorted maps keep the keys sorted. Example of such a map is a TreeMap.
An example of an unsorted map is the HashMap.
I am not sure about the point a.
Hope this helps.
Latha

Originally posted by Aru Ven:
Hi all,
Which of these statements concerning Map are true ?
a. It is permisible for a map to contain itself as a key.
b. values() method return an instance of Set.
c. The Map interface extends the collection interface.
d. All keys in a map are unique.
e. All map implementations keep the keys sorted.
I know that "c" is false.
a. false. It is permisible for a map to contain itself as a value & not as a map
But I am confused about the other options.
the values() method in Map returns a Collection, so does that make "b" true???
And does All map implementations keep the keys sorted.???
Thx in advance
Aruna


 
Enthuware Software Support
Posts: 4907
60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a. is false. A map cannot contain itself as a key (it can contain itself a s a value though).
Such questions are best answered by looking into the API docs. Even tutorials cannot provide complete factual points about the classes. They only give a general idea.
HTH,
Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus
 
reply
    Bookmark Topic Watch Topic
  • New Topic