Collections


  1. Is hashmap an ordered collection.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Hashmap outputs in the order of hashcode of the keys. So it is unordered but will always have same result for same set of keys.


  1. While finding the correct location for saving key value pair, how many times the key is hashed?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The key is hashed twice; first by hashCode() of Object class and then by internal hashing method of HashMap class.



  1. What happens if we put a key object in a HashMap which exists?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    HashMap always contains unique keys. If same key is inserted again, the new object replaces the previous object.


  1. What is the premise of equality for IdentityHashMap?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    IdentityHashMap is rarely used as it violates the basic contract of implementing equals() and hashcode() method.



  1. Which of the below does not implement Map interface?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Vector implements AbstractList which internally implements Collection. Others come from implementing the Map interface.