Respuesta :
Answer:
Option (a) : sam
Explanation:
- In the given program, the queue is defined in the first step.
- The method addToFront() adds the given element to the front of the queue. After this step is executed the front element in the queue is that element.
- The method addToBack() adds the given element to the back of the queue. After this step is executed the back element in the queue is that element.
- After step 1, Jack is added to the front of the queue.
- After step 2, Rudy is added to the back of the queue.
- After step 3, Larry is added to the back of the queue.
- After step 4, sam is added to the front of the queue.
- After step 5, name contains Larry as the getBack() returns the element present at the back of the queue.
- After step 6, Adam is added to the back of the queue.
- After executing all of the steps now the queue contains "sam" as the front element of the queue.
- So, the correct option is "sam".