Learn Code With Durgesh LogoLCWD
HomeCoursesBlogsContact Us
HomeCoursesBlogsContact Us
LearnCodeWithDurgesh Logo

Learn Code With Durgesh

Offering free & premium coding courses to lakhs of students via YouTube and our platform.

Explore

  • About Us
  • Courses
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms & Conditions
  • Refund Policy
  • Support

Contact

  • 📞 +91-9839466732
  • support@learncodewithdurgesh.com
  • Substring Technologies, 633/D/P256 B R Dubey Enclave Dhanwa Deva Road Matiyari Chinhat, Lucknow, UP, INDIA 226028
© 2025 Made with ❤️ by Substring Technologies. All rights reserved.
Most asked Collection framework Interview questions

Most asked Collection framework Interview questions

By durgesh • Fri Nov 04 2022

Most asked Collection framework Interview questions

What is the Collection framework in Java? 

Collection  of the objects is nothing but the Group of any individual objects which are represented as a single unit is collection.In java, collection represents a group of objects as a single unit.

Explain the hierarchy of the Collection framework in Java.

Collection_framework_hirearchy

What are the advantages of the Collection framework?

  • Reduces programming effort

  • Increases program speed and quality

  • Allows interoperability among unrelated APIs

  • Reduces effort to learn and to use new APIs

  • Reduces effort to design new APIs

  • Fosters software reuse

Explain the various interfaces used in the Collection framework.

  • Collection 

  • Set 

  • List

  • Queue

  • Deque

  • Map

  • SortedSet 

  • SortedMap

 

What are the main differences between array and collection?

Array

Collection

Array can only store same type of objects(i.e. Homogeneous objects)

Collection can store different types of objects

Arrays don’t have any inbuilt methods to be used for different operations like searching, sorting etc

Collection framework has different inbuilt methods which can be used for several operations.

Array is static

Collection is dynamic

ArrayList vs LinkedList  vs Vector

Array List

LinkedList

Vector

The ArrayList class is a resizable array

The LinkedList class is a collection which can contain many objects of the same type

The Vector class implements a growable array of objects. Like an array, it contains components that can be accessed using an integer index. 

ArrayList is not synchronized.

LinkedList is not synchronized.

Vector is synchronized.

Arraylist is not thread-safe

Linkedlist is not thread-safe

Vector list is thread-safe

ArrayList is not a legacy class. 

LinkedList is not a legacy class.

Vector is a legacy class.

What is the difference between List and Set?

List

Set

The List interface in Java provides a way to store the ordered collection which maintains the insertion order. It is a child interface of Collection.

Set is an unordered collection which does not preserve the insertion order.

The List can contain duplicate elements

Set includes unique items.

What is the difference between HashSet and TreeSet?

 

HashSet

TreeSet

HashSet is backed by HashMap

TreeSet is backed by TreeMap

HashSet performs faster than TreeSet.

TreeSet performs slower than HashSet.

HashSet maintains no order

TreeSet maintains ascending order.

What is the difference between Set and Map?

Set

Map

Set contains only values

Map contains key and values both.

Set contains only unique values 

Maps can contain unique Keys with duplicate values.

Set holds a single number of null value

Map can include a single null key with n number of null values

What is the difference between HashSet and HashMap?

HashSet

HashMap

HashSet cannot have any duplicate value

HashMap can contain duplicate values with unique keys.

HashSet contains the only single number of null value

HashMap can hold a single null key with n number of null values.

HashSet implements Set interface

HashMap implements the Map interface

 What is the difference between HashMap and TreeMap?

 

HashMap

TreeMap

HashMap maintains no order

TreeMap maintains ascending order.

HashMap can be sorted by Key or value

TreeMap can be sorted by Key.

HashMap is implemented by hash table

TreeMap is implemented by a Tree structure.

HashMap may contain a null key with multiple null values

TreeMap cannot hold a null key but can have multiple null values.

What is BlockingQueue?

java.util.concurrent.BlockingQueue is a java Queue. It provides concurrency in the operations like retrieval, insertion, deletion. It supports operations that wait for the queue to become non-empty when retrieving and removing an element, and wait for space to become available in the queue when adding an element.

What is the advantage of the Properties file?

Java Properties files are useful resources to add information in Java. If any information is changed from the properties file, you don't need to recompile the java class. It is used to store information which is to be changed frequently.

What is the hashCode() method?

The hashCode() method is used to generate the hash values of objects.Using these hash values, these objects are stored in Java collections such as HashMap, HashSet and HashTable.

What is the Dictionary class?

The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. Given a Dictionary and a key, the associated element can be looked up. Any non-null object can be used as a key and as a value.

These are some most important questions asked from the topic collection framework in java. These will give you a short revision of collection framework.

 

 

 

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X

Trending Blogs...

Maven Tutorial

Maven Tutorial

Maven is a build automation tool primarily used for Java projects. It addresses two main aspects of building software: dependency management and project build lifecycle management.

Important DSA Topics for placements

Important DSA Topics for placements

Data Structures and Algorithms (DSA) are fundamental building blocks of computer science. A strong understanding of DSA is essential for every developer, regardless of their specialization.

Amazing Windows key shortcuts in Windows 11

Amazing Windows key shortcuts in Windows 11

Shortcuts are everyone’s favorite, be it in life or in Keyboard. We don’t know about life but we have some amazing shortcut tricks for your keyboard, which are newly introduced in windows 11. Let's have a look and understand these amazing shortcuts to reduce our finger pain

Share this article ...

💬WhatsApp📘Facebook💼LinkedIn🐦X