Tag: Java interview question

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

Why do we have to override the equals() method in Java? We can use the equals method to check equality of two objects. The equals() method of java.lang.Object class acts the same as the == operator; that is, it tests for object identity rather than object equality. The implicit contract of the equals() method, however, is . . . Read more

What is the meaning of hashCode in Java? For every object a unique number generated by JVM which is nothing but hashCode. Hashcode won’t represent an address of the object. JVM will use hashCode while saving the object into hashing related data structures like HashTable, HashSet, HashSet, etc.. The main . . . Read more

What is Daemon thread and How to make Daemon thread? The threads which are executing in the background are called Demon threads. Ex… Garbage Collector, Signal Dispatcher, Attach Listener. The main objective of demon threads is to provide support for non-demon threads(main thread) For ex… If the main thread runs . . . Read more

What is synchronization and why it is important? Synchronized is the modifier applicable only for methods and blocks but not for classes and variables. If multiple threads are trying to operate simultaneously on the same java object then there may be a chance of data-inconsistency problem. To overcome this problem we should go . . . Read more

What is Transient Keyword in Java? Transient modifier applicable only for variables but not for methods and classes. We can use a transient keyword in serialization context. At the time of serialization if we don’t want to save a value of a particular variable to meet security constraint then we . . . Read more