In “How HashMap works in Java“, we learned the internals of HashMap or ConcurrentHashMap class and how they fit into the whole concept. But when the interviewer asks you about HashMap related concepts, he does not stop only on the core concept. The discussion usually goes in multiple d...
implemented on top of HashTable. HashMap stores key-value pairs and doesn’t guarantee the order of the elements. It is also not synchronized. When you create a HashMap in Java then its’ initial capacity is 16 and its’ load factor is 0.75. When the map resizes, its’ capacity ...
9. Difference betweenHashtableandHashMapin Java? (former is thread-safe and doesn't allow null, later is not thread-safe, former is also slow because of whole locking of Map, whileHashMapis fast because of no locking,read more) 10. Difference betweenArrayListandLinkedListin Java? (former i...
In my previous post related to “How HashMap works in java“, I explained the internals of HashMap class and how they fit into whole concept. But when interviewer ask you about HashMap related concepts, he does not stop only on core concept. The discussion usually goes in multiple directio...
Why isStringa popularHashMapkey in Java? Since aStringobject is immutable, its hashcode is cached at the time of creation and it doesn’t need to be calculated again. This makes it a great candidate for the key in a Map since its processing is faster than otherHashMapkey objects. ...
12) How to make HashMap thread-safe? Use Collections.synchronizedMap(new HashMap<>) or ConcurrentHashMap for better concurrent performance. 13) What is the parent class of exceptions in Java? The root class is Throwable, and has two main subclasses: Exception and Error. ...
On the other hand, a problem is deemed to have an optimal substructure if the optimal solution to the given problem can be constructed from optimal solutions of its subproblems. Programming technical interview questions 21. Explain how hash tables work Hashmaps, also known as hashtables, represe...
How HashMap works in Java?HashMap stores key-value pair in `Map.Entry` static nested class implementation. HashMap works on hashing algorithm and uses hashCode() and equals() method in `put` and `get` methods. When we call `put` method by passing key-value pair, HashMap uses Key ...
1 What are new Java8 Features? 2 Difference between GET & POST METHODS? 3 Difference between forward() method & SendRedirect() method? 4 Difference between HashMap and HashTable? 5 Difference between HashSet and TreeSet? 6 What is meant by Collections in Java? 7 What is meant by Ordered...
f2 is stored in a file as a3.java The compiler will compile the three files and produces 3 corresponding .class file which consists of BYTE code. Unlike C, no linking is done . The Java VM or Java Virtual Machine resides on the RAM. During execution, using the class loader the class ...