Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Java 10 questions

Collections Framework (List, Set, Map)

Master Java collections. Differentiate ArrayList vs LinkedList, HashSet vs TreeSet, HashMap vs TreeMap, and sorting interfaces.

More Java
Interview questions 1–10 of 10
1

What is the Java Collections Framework and what are its core interfaces?

The Collections Framework is a unified architecture for storing and manipulating groups of objects, providing...

Read answer →
2

What is the difference between ArrayList and LinkedList?

AspectArrayListLinkedListInternal structureDynamic arrayDoubly linked listRandom access (get(i))O(1) - fastO(n...

Read answer →
3

How does HashMap work internally in Java?

HashMap stores key-value pairs in an array of buckets. A key's hashCode() determines which bucket it goes into...

Read answer →
4

What is the difference between HashMap, LinkedHashMap, and TreeMap?

ClassOrderingPerformanceNull keysHashMapNo guaranteed orderO(1) average for get/putOne null key allowedLinkedH...

Read answer →
5

What is the difference between HashSet, LinkedHashSet, and TreeSet?

All three implement the Set interface (no duplicates), but differ in ordering guarantees and underlying implem...

Read answer →
6

What is the difference between Comparable and Comparator in Java?

AspectComparableComparatorPackagejava.langjava.utilMethodcompareTo(Object o)compare(Object o1, Object o2)Sorti...

Read answer →
7

How do you iterate over a Map in Java?

Map<String, Integer> map = new HashMap<>(); map.put('apple', 10); map.put('banana', 20); map.put('cherry', 30)...

Read answer →
8

What is the difference between fail-fast and fail-safe iterators in Java?

TypeBehavior on modification during iterationExamplesFail-fastThrows ConcurrentModificationException immediate...

Read answer →
9

What is the difference between Collections and Collection in Java?

TermWhat it isCollectionRoot interface of the framework (List, Set, Queue extend it)CollectionsUtility class w...

Read answer →
10

How do you make a custom object usable as a HashMap key?

To use a custom class as a HashMap key correctly, you must override both hashCode() and equals() consistently...

Read answer →