Exam 15: The Java Collections Framework
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
Which of the following algorithms would be efficiently executed on an ArrayList?
Free
(Multiple Choice)
4.9/5
(35)
Correct Answer:
D
The ArrayList class implements the ____.
Free
(Multiple Choice)
4.9/5
(42)
Correct Answer:
C
Consider the code snippet shown below. Assume that employeeNames is an instance of type LinkedList<String>. for (String name : employeeNames)
{
// Do something with name here
}
Which element(s) of employeeNames does this loop process?
Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
B
Select an appropriate expression to complete the following code segment, which is designed to print a message if the string stored in name is part of the players collection. Collection<String> players = new ArrayList<String>();
// code to add elements to the collection here
If ______________________________________
System.out.print(name + " is one of the players in the collection.");
(Multiple Choice)
4.7/5
(39)
Assuming that names is a Queue of String objects, select a statement to complete the code segment below. The code is designed to remove the last element from the queue, which is guaranteed to have at least one element. Queue<String> aQueue = new LinkedList<String>();
While (names.size() > 1)
{
AQueue.add(names.remove());
}
Names.remove();
While (aQueue.size() > 0)
{
____________________________
}
(Multiple Choice)
4.8/5
(39)
Rather than storing values in an array, a linked list uses a sequence of ____.
(Multiple Choice)
4.7/5
(35)
A collection that allows speedy insertion and removal of already-located elements in the middle of it is called a ____.
(Multiple Choice)
4.9/5
(36)
Select an appropriate expression to complete the following method, which is designed to return the number of elements in the parameter array numbers. If a value appears more than once, it should be counted exactly once. public static int countElementsOnce(int[] numbers)
{
Set<Integer> values = new HashSet<Integer>();
For (int num: numbers)
{
Values.add(num);
}
______________________
}
(Multiple Choice)
4.9/5
(34)
Assume that you have declared a map named myMap to hold String elements with Integer keys. Which of the following statements will correctly insert an element into myMap?
(Multiple Choice)
4.8/5
(31)
Which of the following statements about hash functions is NOT correct?
(Multiple Choice)
5.0/5
(37)
Complete the following code, which is intended to print out all key/value pairs in a map named myMap that contains String data for student IDs and names: Map<String, String> myMap = new HashMap<String, String>();
) . .
Set<String> mapKeySet = myMap.keySet();
For (String aKey : mapKeySet)
{
___________________________;
System.out.println("ID: " + aKey + "->" + name);
}
(Multiple Choice)
4.8/5
(40)
When using a list iterator, on which condition will the IllegalStateException be thrown?
(Multiple Choice)
4.8/5
(40)
Select an appropriate declaration to complete the following code segment, which is designed to read strings from standard input and display them in increasing alphabetical order, excluding any duplicates. _________________________________________
Scanner input = new Scanner(System.in);
While (input.hasNext())
{
Words.add(input.next());
}
System.out.print(words);
(Multiple Choice)
4.7/5
(38)
What is the meaning of the type parameter E, in the LinkedList<E> code fragment?
(Multiple Choice)
4.9/5
(28)
You intend to use a hash set with your own object class. Which of the following statements is NOT correct?
(Multiple Choice)
4.8/5
(35)
Consider the code snippet shown below: Stack<String> words1 = new Stack<String>();
Stack<String> words2 = new Stack<String>();
Words1.push("abc");
Words1.push("def");
Words1.push("ghi");
While (!words1.empty())
{
Words2.push(words1.pop());
}
While (!words2.empty())
{
System.out.print(words2.pop());
}
What will be printed when this code is executed?
(Multiple Choice)
4.9/5
(44)
Assume you have created a linked list name myList that currently holds some number of String objects. Which of the following statements correctly removes an element from the end of myList?
(Multiple Choice)
4.8/5
(40)
Which of the following statements about the LinkedList class is correct?
(Multiple Choice)
4.8/5
(41)
Which data structure would best be used for finding a path out of a maze?
(Multiple Choice)
4.8/5
(36)
Showing 1 - 20 of 110
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)