QUESTION 10 Assume you have created a linked list namde myList that currently ho
ID: 3819607 • Letter: Q
Question
QUESTION 10
Assume you have created a linked list namde myList that currently holds some number of String objects. Which of the following statements correctly adds a new element to the beginning of myList?
myList.addFirst("Harry");
myList.add("Harry");
myList.insert("Harry");
myList.put("Harry");
1 points
QUESTION 11
Consider the following code snippet:
What output will be produced when this code is executed?
ab,abc,a,
a,abc,ab,
a,ab,abc,
abc,ab,a,
1 points
QUESTION 12
You need to access values by their position. Which collection type should you use?
TreeSet
ArrayList
Stack
Queue
1 points
QUESTION 13
What can a generic class be parameterized for?
properties
iterators
type
methods
1 points
QUESTION 14
Which method is NOT part of the ListIterator interface?
delete
add
next
previous
1 points
QUESTION 15
You want to enumerate all of the keys in a map named myMap whose keys are type String. Which of the following statements will allow you to do this?
1 points
QUESTION 16
In a linked list data structure, when does the reference to the first node need to be updated?
I inserting into an empty list
II deleting from a list with one node
III deleting an inner node
I
II
I and II
III
1 points
QUESTION 17
Which of the following algorithms would be efficiently executed using a LinkedList?
Tracking paths in a maze.
Binary search.
Remove first n/ 2 elements from a list of n elements.
Read n / 2 elements in random order from a list of n elements.
1 points
QUESTION 18
To create a TreeSet for a class of objects, the object class must ____.
create an iterator.
implement the Comparable interface.
implement the Set interface.
create a Comparator object.
1 points
QUESTION 19
You need to write a program to simulate the effect of adding an additional cashier in a supermarket to reduce the length of time customers must wait to check out. Which data structure would be most appropriate to simulate the waiting customers?
map
stack
queue
linked list
1 points
QUESTION 20
What is the meaning of the type parameter E, in the LinkedList<E> code fragment?
The elements of the linked list are of class E.
The elements of the linked list are of any subclass of class E.
The elements of the linked list are any type supplied to the constructor.
The elements of the linked list are of class Object.
myList.addFirst("Harry");
myList.add("Harry");
myList.insert("Harry");
myList.put("Harry");
Explanation / Answer
QUESTION 10 : myList.addFirst("Harry");
addFirst() method adds at the begining of the list.
QUESTION 11 : ab,abc,a,
The element added first will be removed first in queue.
QUESTION 12: ArrayList
get(index) method is used to get any element in the arraylist.
QUESTION 13: type
generics are used to different datatypes
QUESTION 14: delete
it has remove() method not delete()
QUESTION 15 :
QUESTION 16 : I and II
I inserting into an empty list
II deleting from a list with one node
QUESTION 17 :
Read n / 2 elements in random order from a list of n elements.
QUESTION 18: create a Comparator object.
QUESTION 19: queue
QUESTION 20: The elements of the linked list are of class E.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.