Collections


  1. Which of these method is used add an element and corresponding key to a map?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Maps revolve around two basic operations – get() and put(). to put a value into a map, use put(), specifying the key and the value. To obtain a value, call get() , passing the key as an argument. The value is returned.


  1. Which of these methods can be used to obtain set of all keys in a map?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    keySet() methods is used to get a set containing all the keys used in a map. This method provides set view of the keys in the invoking map.



  1. Which of these method Map class is used to obtain an element in the map having specified key?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    get()


  1. Which of these method is used to remove all keys/values pair from the invoking map?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    remove()



  1. Which of these classes provide implementation of map interface?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    AbstractMap, WeakHashMap, HashMap and TreeMap provide implementation of map interface.