asked 26.1k views
5 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

asked
User Maarti
by
8.5k points

1 Answer

3 votes

Answer:

C.Rudy.

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 front now we have Rudy at the front and all other elements are added to back.So Rudy is at the front.

answered
User CCSJ
by
7.8k points