What is the Advantage of Properties File in Java?

If you change the value in the properties file, you don't need to recompile the java class. So, it makes the application easy to manage. It is used to store information which is to be changed frequently. 

What is BlockingQueue in Java?

BlockingQueue is an interface which extends the Queue interface. It provides concurrency in the operations like retrieval, insertion, deletion. While retrieval of any element, it waits for the queue to be non-empty. While storing the elements, it waits for the available space. BlockingQueue cannot contain null elements, and implementation of BlockingQueue is thread-safe.

public interface BlockingQueue<E> extends Queue <E>  

What is the Difference between Comparator and Comparable in Java?

Here are the differences:

 ComparableComparator
Sort of SequenceOnly OneMultiple Sort of Sequences
Method UsedcompareTo()compare()
packagejava.langjava.util.package
ImplementationActual class is modifiedActual Class not changed

What is the difference between Java Collection and Java Collections?

The differences between the Collection and Collections are given below.

  • The Collection is an interface whereas Collections is a class.
  • The Collection interface provides the standard functionality of data structure to List, Set, and Queue. However, Collections class is to sort and synchronize the collection elements.
  • The Collection interface provides the methods that can be used for data structure whereas Collections class provides the static methods which can be used for various operation on a collection.

What is difference between TreeMap and HashMap in Java?

The differences between the HashMap and TreeMap are given below.

 HashMapTreeMap
OrderNo OrderAscending Order
Implemented ByHash TableTree Structure
Sort ByKey or ValueKey
Null ValueNull Key - 1, Null Values - MultipleNull Key - 0, Null Values - Multiple

What is difference between HashSet and HashMap in Java?

The differences between the HashSet and HashMap are listed below.

 HashSetHashMap
Key & ValueContains only ValueContains Entry - Key & Value
IteratedDirectly IteratedConvert into Set to iterate
Duplicate ValuesNo duplicate valuesUnique Keys, Duplicate Values
Null ValuesSingle Null ValueSingle Null Key, N number of null values

What is difference between Set and Map in Java?

The differences between the Set and Map are given below.

 SetMap
ContainsValueKey + Value
Unique ValuesUnique ValuesUnique Keys, Duplicate Values
Null ValuesSingle Null ValueSingle Null Key, N number of null values

What is the difference between HashSet and TreeSet in Java?

The HashSet and TreeSet, both classes, implement Set interface. The differences between the both are listed below.

 HashSetTreeSet
OrderNo OrderAscending Order
Implemented ByImpended by Hash TableImplemented by Tree Structure
SpeedFasterSlow
Backed ByHash MapTree Map

What is the difference between List and Set in Java?

The List and Set both extend the collection interface. However, there are some differences between the both which are listed below.

 ListSet
Duplicate ElementsDuplicate Unique
Maintain Insertion OrderYesNo
Legacy ClassYes - VectorNo
Null ValuesN number of1 only
teststep banner