Tag: Core java interview

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 . . . Read more

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 . . . Read more

Java Set is a collection of elements (Or objects) that contains no duplicate elements. Java Set is an interface that extends Collection interface. Unlike List, Java Set is NOT an ordered collection, it’s elements does NOT have a particular order. Java Set does NOT provide a control over the position where you . . . Read more

Explain ArrayList and difference between ArrayList and Vector? ArrayList is a class, that uses a dynamic array for storing the elements. It extends AbstractList class and implements List interface. The underlying data structure is a Resizable array or growable array. Duplicates are allowed. Insertion order is preserved. Heterogeneous objects are . . . Read more

How many ways can we make an object eligible for GC? Even through programmer is not responsible to destroy useless objects it is highly recommended to make an object eligible for GC. If it no longer a requirement. The garbage collector will look for objects which aren’t being used anymore . . . Read more

Difference between yield(), join(), sleep() method? We can prevent thread execution by using the following method. yield() join() sleep() public static native void yield()Â yield() method causes to pause current executing thread to give the chance for waiting threads of the same priority. If there is no waiting thread or . . . Read more