Frequently Asked Java Collection Interview Questions


Posted August 17, 2017 by ellengomez0122

Java Collection Framework (JCF) is used to collect data in ordered structures in Java

 
Java Collection Framework (JCF) is used to collect data in ordered structures in Java, unlike arrays Collections does not possess a definite size rather they alter their size depending upon the data fed. Technically, JCF is a set of classes and interfaces that implement commonly reusable collection data structures. Collections and arrays are similar in that they both hold references to objects and they can be managed as a group. However, unlike arrays, collections do not need to be assigned a certain capacity when instantiated. Collections can also grow and shrink in size automatically when objects are added or removed. Collections cannot hold basic data type elements (primitive types) such as int, long, or double; instead, they hold Wrapper Classes such as Integer, Long, or Double.

When asked about in an interview, Collections can prove to be of immense importance as they could be used as a tool to check in-depth knowledge of a person, the most Collection based questions asked in an interview are:

• What is the difference between ArrayList and Vector?
The answer to that may be summed up in three distinct points, synchronicity, legacy class and size. Both ArrayList and Vector has contrasted structures.

•What is the difference between Iterator and ListIterator?
The answer to which could be framed as Iterator traverses the elements in a forward direction only whereas ListIterator traverses the elements in forward and backward direction.

• 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.

• Why we override an equals() method?
The equals method is used to check whether two objects are same or not. It needs to be overridden if we want to check the objects based on the property.

• What is the Dictionary class?
The Dictionary class provides the capability to store key-value pairs.

• What is the hash-collision in a hashtable and how it is handled in Java?
Two different keys with the same hash value are known as hash-collision. Two different entries will be kept in a single hash bucket to avoid the collision.

• What is the advantage of a generic collection?
If we use a generic class, we don't need typecasting. It is typesafe and checked at compile time.


There are several other direct questions which could be asked in an interview such as :

• What is the difference between ArrayList and LinkedList?

• What is the difference between Iterator and Enumeration?

• What is the difference between List and Set?

• What is the difference between Set and Map?

• How to synchronize List, Set and Map elements?

About Us:
We provide the best of Java solutions in every sector. The margin of error in our work in minimum as we thrive to make our customers' experience best possible. We have a great team of technical professional who will execute your work perfectly.

Contact Us: Pune, India.
http://www.java2blog.com/
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By ellen gomez
Website Java2blog
Business Address Pune, India
Country India
Categories Education , Engineering , Free
Tags core java interview questions , how to learn java programming , java collections interview questions , java interview questions , java tutorial for beginners
Last Updated August 17, 2017