Tag Archives: Collection interview question

What is Arrays class in Java?

What is Arrays class in Java?

What is Arrays class in Java? Arrays class is a utility class to define several utility methods for array objects.  We can sort primitive arrays only based on default natural sorting order whereas we can sort object arrays either based on default natural sorting order or based on customized sorting order Sorting elements of the array  1 Public static void ...

Read More »

What is a Collection class in Java?

What is a Collection class in Java?

What is a Collection class in Java? Collections class defines several utility methods for collection objects like sorting, searching, reversing, etc.  Sorting elements of List  Collections class defines the following two methods for sorting. 1 Public static void sort(List l) To sort based on default natural sorting order In this case list should compulsory contain homogenous and comparable objects otherwise ...

Read More »

What is Hashtable in Java with Example?

What is Hashtable in Java with Example?

What is Hashtable in Java with Example? What is Hashtable in Java with Example? The underlying data-structure for Hashtable is Hashtable. Insertion order is not preserved and it is based on Hashcode of keys. Duplicate keys are not allowed and values can be duplicated. Heterogeneous objects are allowed for both keys and values. Null is not allowed for both key and ...

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 »

What is IdentityHashMap?

What is IdentityHashMap?

What is IdentityHashMap? In journal == operator meant for reference comparison (address comparison) and equals() method meant for content comparison. It is exactly same as HashMap(including methods and constructors) except the following difference. In the case of normal HashMap, JVM will use .equals() method to identify duplicates keys, which is meant for content comparison. But in the case of identity HashMap JVM will ...

Read More »

Difference between HashMap & Hashtable in Java?

Difference between HashMap & Hashtable in Java?

Difference between HashMap & Hashtable in Java? The underlying data-structure is HashTable. Insertion order is not preserved and it is based on HashCode is keys. Duplicate keys are not allowed but values can be duplicated. Heterogeneous objects are allowed for both Key and value. Null is allowed for Key(only once). Null is allowed for values(Any numbers of times). HashMap implements ...

Read More »

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