Tag Archives: Collections interview question

What is TreeMap in Java with example?

What is TreeMap in Java with example?

  What is TreeMap in Java with example? The underlying data-structure is Red-black-Tree. Insertion order is not preserved and it is based on some sorting order of keys. Duplicate key is not allowed but values can be duplicated. If we are depending on default natural sorting order then keys should be heterogeneous and comparable. Otherwise, we will get Runtime exception saying ...

Read More »

What is WeakHashMap in Java?

What is WeakHashMap in Java?

  What is WeakHashMap in Java? It is exactly same as HashMap except for the following difference:- In the case of HashMap even though object doesn’t have any reference it is not eligible for GC. If it is associated with HashMap that is HashMap dominates Garbage collector. But in the case of WeakHashMap, if the object doesn’t contain any references ...

Read More »

Difference between HashMap and LinkedHashMap?

Difference between HashMap and LinkedHashMap?

Difference between HashMap and LinkedHashMap? It is the child class of HashMap. The LinkedHashMap class is very similar to HashMap in most aspects. However, the linked hash map is based on both hash table and the linked list to enhance the functionality of hash map. It maintains a doubly-linked list running through all its entries in addition to an underlying array of default size ...

Read More »

What is a Collection Framework in Java?

What is a Collection Framework in Java?

What is a Collection Framework in Java? If we want to represent a group of an individual object as a single entity then we should go for collection. It contains several classes and interfaces which can be used to represent a group of an individual object as a single entity. You can perform following activity using Java collection framework, Add objects to ...

Read More »

Responsive WordPress Theme Freetheme wordpress magazine responsive freetheme wordpress news responsive freeWORDPRESS PLUGIN PREMIUM FREEDownload theme free