Flashcards on Java Collections

Click on the flashcard to see the answer


What are the key interfaces of the Java Collections Framework?

The key interfaces of the Java Collections Framework are List, Set, Queue, Map and their sub-interfaces.

What is the difference between ArrayList and LinkedList?

ArrayList is faster for adding and removing elements from the end of the list, whereas LinkedList is faster for adding and removing elements from the middle of the list.

What is the purpose of the java.util package in Java Collections Framework?

The java.util package contains the classes and interfaces for the Java Collections Framework.

What is the difference between HashSet and TreeSet in Java Collections Framework?

HashSet doesn't maintain the elements in any order whereas TreeSet maintains the elements in a sorted order.

What is the difference between HashMap and HashTable in Java Collections Framework?

HashMap is not synchronized, whereas HashTable is synchronized.

What is the difference between List and Set interfaces in Java Collections Framework?

List interface allows duplicate elements, whereas Set interface doesn't allow duplicate elements.

What is the difference between Iterator and ListIterator in Java Collections Framework?

Iterator can only traverse in forward direction, whereas ListIterator can traverse in both forward and backward directions.

What is the difference between Arrays.asList() and ArrayList in Java Collections Framework?

Arrays.asList() method returns a fixed-length list backed by the array, whereas ArrayList is dynamic in size.

What is the difference between Comparator and Comparable interfaces in Java Collections Framework?

Comparator interface is used to sort objects based on multiple attributes, whereas Comparable interface is used to sort objects based on a single attribute.

What is the use of the Collections class in Java Collections Framework?

The Collections class provides various utility methods for sorting, searching, reversing, and synchronizing collections.

What is the difference between Array and ArrayList in Java Collections Framework?

Array is a fixed-size container, whereas ArrayList is a dynamic container.

What is the purpose of the Queue interface in Java Collections Framework?

The purpose of the Queue interface is to maintain the order of elements and process them in a first-in-first-out (FIFO) manner.

What is the use of the TreeMap class in Java Collections Framework?

The TreeMap class is used to store key-value pairs in a sorted order based on the key. It implements the NavigableMap interface.

What is the use of the Hashtable class in Java Collections Framework?

The Hashtable class is used to store key-value pairs in a hash table. It is synchronized and doesn't allow null key or value.

What is the difference between Enumeration and Iterator in Java Collections Framework?

Enumeration is used to traverse legacy collections, whereas Iterator is used to traverse modern collections. Iterator is more efficient and allows removal of elements during traversal.

What are the key interfaces of the Java Collections Framework?

The key interfaces of the Java Collections Framework are List, Set, Queue, Map and their sub-interfaces.

What is the difference between ArrayList and LinkedList?

ArrayList is faster for adding and removing elements from the end of the list, whereas LinkedList is faster for adding and removing elements from the middle of the list.

What is the purpose of the java.util package in Java Collections Framework?

The java.util package contains the classes and interfaces for the Java Collections Framework.

What is the difference between HashSet and TreeSet in Java Collections Framework?

HashSet doesn't maintain the elements in any order whereas TreeSet maintains the elements in a sorted order.

What is the difference between HashMap and HashTable in Java Collections Framework?

HashMap is not synchronized, whereas HashTable is synchronized.

What is the difference between List and Set interfaces in Java Collections Framework?

List interface allows duplicate elements, whereas Set interface doesn't allow duplicate elements.

What is the difference between Iterator and ListIterator in Java Collections Framework?

Iterator can only traverse in forward direction, whereas ListIterator can traverse in both forward and backward directions.

What is the difference between Arrays.asList() and ArrayList in Java Collections Framework?

Arrays.asList() method returns a fixed-length list backed by the array, whereas ArrayList is dynamic in size.

What is the difference between Comparator and Comparable interfaces in Java Collections Framework?

Comparator interface is used to sort objects based on multiple attributes, whereas Comparable interface is used to sort objects based on a single attribute.

What is the use of the Collections class in Java Collections Framework?

The Collections class provides various utility methods for sorting, searching, reversing, and synchronizing collections.

What is the difference between Array and ArrayList in Java Collections Framework?

Array is a fixed-size container, whereas ArrayList is a dynamic container.

What is the purpose of the Queue interface in Java Collections Framework?

The purpose of the Queue interface is to maintain the order of elements and process them in a first-in-first-out (FIFO) manner.

What is the use of the TreeMap class in Java Collections Framework?

The TreeMap class is used to store key-value pairs in a sorted order based on the key. It implements the NavigableMap interface.

What is the use of the Hashtable class in Java Collections Framework?

The Hashtable class is used to store key-value pairs in a hash table. It is synchronized and doesn't allow null key or value.

What is the difference between Enumeration and Iterator in Java Collections Framework?

Enumeration is used to traverse legacy collections, whereas Iterator is used to traverse modern collections. Iterator is more efficient and allows removal of elements during traversal.

Share


Login to Save


Share



Login to Save


Explore Other Decks


Made for Grade 8

Low Level Languages, High Level Languages and Translation Programs


View Deck
Made for Grade 8

Maria Manoru 'Charlotte Obtaining... 13 Points'


View Deck
Made for Grade 3

Meghan Mac Donald 'Judy Moody meets a new teacher'


View Deck

Explore More