115k views
4 votes
)What item is at the front of the list after these statements are executed?

DequeInterface waitingLine= new LinkedDeque<>();

WaitingLine.addToFront("Jack");

WaitingLine.addToFront("Rudy");

WaitingLine.addToBack("Larry");

WaitingLine.addToBack("sam");

String name =waitingLine.getFront();

A.sam B. Larry. C. Rudy. D. Jack

User Stackmate
by
4.8k points

1 Answer

2 votes

Answer:

C.Rudy

Step-by-step explanation:

A deque waitingLine is created.Then Jack is added to front of the deque first.After that Rudy is added to the front of the deque.AFter that Larry and sam are inserted at the back.So the last item inserted at the front is front of the deque.So Rudy was the last item inserted at the front.

Hence we conclude that the answer is Rudy.

User Seif Tml
by
4.9k points