Java OCA OCP Practice Question 1135

Question

You can determine all the keys in a Map in which of the following ways?

  • A. Getting a Set object from the Map and iterating through it.
  • B. Iterating through the Iterator of the Map.
  • C. Enumerating through the Enumeration of the Map.
  • D. Getting a List from the Map and enumerating through the List.
  • E. You cannot determine the keys in a Map.


A.

Note

The key and value pairs in Map does not have a sequence, therefore you cannot get a List from them.

A Map contains a Set, which is a list that does not allow duplicates.

Once you acquire the Set you can iterate through the keys.




PreviousNext

Related