Java

TOPIC 22 – QUEUES & STACKS

 

LESSON WORK

 

 

QUESTION 1

Create a Queue object that stores names.

Add five names in the queue.

Output the queue to screen.

Remove a name from the queue.

Output the queue to screen.  (Notice that the first name entered is the one removed.)

 

QUESTION 2


Create a Stack object that stores integers.

Add numbers to the stack.

Output the stack to screen.

Pop a number off the stack.  (Pop means remove.)

Output the stack to screen.  (Notice that the last number entered is the one removed.)