MCQOPTIONS
Saved Bookmarks
This section includes 9 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
If large number of items are stored in hash bucket, what happens to the internal structure? |
| A. | The bucket will switch from LinkedList to BalancedTree |
| B. | The bucket will increase its size by a factor of load size defined |
| C. | The LinkedList will be replaced by another hashmap |
| D. | Any further addition throws Overflow exception |
| Answer» B. The bucket will increase its size by a factor of load size defined | |
| 2. |
How to externally synchronize hashmap?a) HashMap.synchronize(HashMap |
| A. | HashMap.synchronize(HashMap a); |
| B. | |
| C. | Collections.synchronizedMap(new HashMap<String, String>()); |
| D. | Collections.synchronize(new HashMap<String, String>());View Answer |
| Answer» D. Collections.synchronize(new HashMap<String, String>());View Answer | |
| 3. |
If two threads access the same hashmap at the same time, what would happen? |
| A. | ConcurrentModificationException |
| B. | NullPointerException |
| C. | ClassNotFoundException |
| D. | RuntimeException |
| Answer» B. NullPointerException | |
| 4. |
What happens if we put a key object in a HashMap which exists? |
| A. | The new object replaces the older object |
| B. | The new object is discarded |
| C. | The old object is removed from the map |
| D. | It throws an exception as the key already exists in the map |
| Answer» B. The new object is discarded | |
| 5. |
What is the premise of equality for IdentityHashMap? |
| A. | Reference equality |
| B. | Name equality |
| C. | Hashcode equality |
| D. | Length equality |
| Answer» B. Name equality | |
| 6. |
Which of the below does not implement Map interface? |
| A. | HashMap |
| B. | Hashtable |
| C. | EnumMap |
| D. | Vector |
| Answer» E. | |
| 7. |
Map implements collection interface? |
| A. | True |
| B. | False |
| Answer» C. | |
| 8. |
Is hashmap an ordered collection. |
| A. | True |
| B. | False |
| Answer» C. | |
| 9. |
While finding the correct location for saving key value pair, how many times the key is hashed? |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | unlimited till bucket is found |
| Answer» C. 3 | |