25+ Advanced Java Collections Interview Questions 2020-2021 - 1

Question: 1

What is the difference between enumeration and iterator interface?

Enumeration is twice as fast as Iterator and uses very less memory. Enumeration is very basic and fits to basic needs. But Iterator is much safer as compared to Enumeration because it always denies other threads to modify the collection objects which is being iterated by it.

Iterator takes the place of Enumeration in the Java Collections Framework. Iterators allow the caller to remove elements from the underlying collection that is not possible with Enumeration. Iterator method names have been improved to make its functionality clear.

Question: 2

java.util.regex consists of which classes?

java.util.regex consists of three classes: Pattern class, matcher class and PatternSyntaxException class.

Question: 3

What is the advantage of properties file?

If you change the value in properties file, you don’t need to recompile the java class. So, it makes the application easy to manage.

Question: 4

What is the vector class?

  • The vector class implements an incremental array of objects.
  • The vector components can be accessed using an integer index.
  • The size of a Vector increases or decreases as needed to accommodate the items.

Question: 5

What is hash collision in hash table and how it is handled in java?

Two different keys with the same hash value is known as hash collision.

Two different entries will be kept in a single hash bucket to avoid the collision.

Related Questions