QUESTION 1 Consider the following code snippet: What output will be produced whe
ID: 3818052 • Letter: Q
Question
QUESTION 1
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 2
Which of the following statements about sets is correct?
Inserting and removing elements that have already been located is faster with a list than with a set.
A set allows duplicate values.
You can add an element to a specific position within a set.
A set is a collection of unique elements organized for efficiency.
1 points
QUESTION 3
Assume that you have declared a set named mySet to hold String elements. Which of the following statements will correctly insert an element into mySet?
mySet.insert("apple");
mySet.put(apple");
mySet.push("apple");
mySet.add("apple");
1 points
QUESTION 4
Which of the following correctly declares a stack that will hold String elements?
Stack<String> s = new Stack<String>();
Stack s = new Stack<String>();
String s = new Stack<String>();
String s = new Stack();
1 points
QUESTION 5
Which data structure would best be used for keeping track of a growing set of groceries to be purchased at the food market?
queue
stack
list
array
1 points
QUESTION 6
Rather than storing values in an array, a linked list uses a sequence of ____.
indexes
nodes
elements
accessors
1 points
QUESTION 7
What operation is least efficient in a LinkedList?
Adding an element in a position that has already been located.
Linear traversal step.
Removing an element when the element's position has already been located.
Random access of an element.
1 points
QUESTION 8
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:
String name = myMap.get(aKey);
String name = myMap.next(aKey);
String name = MapKeySet.get(aKey);
String name = MapKeySet.next(aKey);
1 points
QUESTION 9
Assume that you have declared a stack named myStack to hold String elements. Which of the following statements will correctly add an element to myStack?
myStack.put("apple");
myStack.addItem("apple");
myStack.push("apple");
myStack.insert("apple");
1 points
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.
1 points
Click Save and Submit to save and submit. Click Save All Answers to save all answers.
ab,abc,a,
a,abc,ab,
a,ab,abc,
abc,ab,a,
Explanation / Answer
There are so many questions to do at once. I am providing you the answers for first 10 questions. Please post the other 10 questions seperately.
Answer 1) b
stringQueue.remove() will remove from last element to first.
Answer 2) d
A set is a collection of unique elements organized for efficiency.
Answer 3) d
mySet.add("apple");
Answer 4) a
Stack<String> s = new Stack<String>();
Answer 5) c
list
Answer 6) b
nodes
Answer 7) d
Random access of an element.
Answer 8) c
String name = MapKeySet.get(aKey);
Answer 9) c
myStack.push("apple");
Answer 10) a
myList.addFirst("Harry");
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.