87.8k 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.addTolBack("Rudy");

WaitingLine.addToBack("Larry");

WaitingLine.addTolFront("sam");

name =getBack();

WaitingLine.addtoBack("Adam");

A.sam B. Adam. C. Rudy. D. Jack E. all other answers

1 Answer

4 votes

Answer:

A.Sam.

Step-by-step explanation:

We are using Deque interface which is sub type of Queue interface. Deque supports insertion and deletion from both ends front and end.So it can be used as a queue and stack also.

In this question we have inserted Jack at the front first.Then Rudy at the back then larry also at the tail.Now we have added sam at the front then nothing is added to the front.So the answer is Sam.

User Hoang Trung
by
5.3k points