Collections Flashcards
What does the Java API provide for data structures?
Predefined data structures called collections
Collections are used to store groups of related objects in memory.
What is the main purpose of the Collection interface?
Defines common operations for lists, vectors, stacks, queues, priority queues, and sets.
What are the two types of containers supported by the Java Collections Framework?
- Collection
- Map
What type of elements do Sets store?
Nonduplicate elements.
How do Lists store elements?
In an ordered collection.
Describe how Stacks process objects.
In a last-in, first-out fashion.
Describe how Queues process objects.
In a first-in, first-out fashion.
How do PriorityQueues process objects?
In the order of their priorities.
What is the root interface for manipulating a collection of objects in Java?
Collection interface.
What is the significance of the placeholder ‘T’ in ArrayList<T>?</T>
It is a placeholder for the type of elements the ArrayList will hold.
What are generic classes in Java?
Classes that can be used with any type.
What does boxing refer to in Java?
Wrapping primitive values as objects.
What does unboxing refer to in Java?
Extracting primitive values from their corresponding object.
What does the Iterable interface provide?
A method to obtain an Iterator object to traverse elements.
What is the purpose of the Iterator interface?
Provides a uniform way for traversing elements in various types of collections.