Java Coding Interview Questions – Collections

This is first part of the coding interview questions. You may refer the complete list here : Java Coding Interview Questions – Part 1 Java Coding Interview Questions – Part 2 Java Coding Interview Questions – Part 3 Java Coding Interview Questions – Part 4 Java Coding Interview Questions – Part 5 Java Coding Interview […]

HashMap, ConcurrentHashMap, HashTable and Collections.synchronizedMap differences

Question 1   Differences between HashMap and Hashtable ? (OR) What are the differences between a HashMap and a Hashtable in Java?   Answer   There are several differences between HashMap and Hashtable in Java: – Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform […]

ArrayList Interview Questions

In this article we will cover frequently asked ArrayList interview questions.   How can we obtain an array from an arraylist class ?   How to convert an array to arraylist?   ArrayList is resizable . So, can we add elements to an ArrayList obtained from Arrays.asList() ?   What is the differences between ArrayList […]

Top java puzzles

HashMap Interview Questions in Java

This article provides a collection of frequently asked Java HashMap Interview Questions interview questions and answers.   Java HashMap Interview Questions Can we synchronize a HashMap ?   Can we add duplicate keys in a HashMap ?   What happens to the value if we add a duplicate key with new value ? Is is […]

Java Collections Interview Questions

1 – Difference between HashTable and HashMap HashMap is not threadsafe whereas HashTable is threadsafe Since HashMap is not synchronized it performs better than HashTable Hashtable does not allow null key, hashmap allows 1 null key & several null values Iterator in hashmap is fail-fast. But enum in Hashtable is not fail-fast. Fail-fast means if […]