WorksheetsData Structures
Total questions: 10
Worksheet time: 7mins
Which of these inserts elements into a Queue? Select all that apply.
push()
offer()
add()
insert()
Which of these inserts elements into a Stack? Select all that apply.
push()
offer()
add()
insert()
Which of these inserts elements into a Deque? Select all that apply.
pushFirst()
offerFirst()
addFirst()
insertFirst()
Which of these removes elements from a Queue? Select all that apply.
pop()
poll()
peek()
remove()
Which of these removes elements from a Stack? Select all that apply.
pop()
poll()
peek()
remove()
Which of these removes elements from a Deque? Select all that apply.
popFirst()
pollFirst()
peekFirst()
removeFirst()
Deque<Integer> d = [1,2,3].
d.offerLast(d.pollFirst());
What is the value of d?
[1,2,3]
[2,3,1]
[3,1,2]
[3,2,1]
Deque<Integer> d = [1,2,3].
d.offerFirst(d.pollLast());
What is the value of d?
[1,2,3]
[2,3,1]
[3,1,2]
[3,2,1]
Consider two Deques with the same element type, A and B, and let B be empty.
To move everything from A to B and preserve order, which of these can be used in a loop? Select all that apply.
B.offerFirst(A.pollFirst());
B.offerFirst(A.pollLast());
B.offerLast(A.pollFirst());
B.offerLast(A.pollLast());
Consider two Deques with the same element type, A and B, and let B be empty.
To move everything from A to B and reverse order, which of these can be used in a loop? Select all that apply.
B.offerFirst(A.pollFirst());
B.offerFirst(A.pollLast());
B.offerLast(A.pollFirst());
B.offerLast(A.pollLast());
