Question: Question 5 (30 pts total) You will implement Stack and Queue classes in Java using an ArrayList of Objects. Since java already has Stack and

 Question 5 (30 pts total) You will implement Stack and Queue

Question 5 (30 pts total) You will implement Stack and Queue classes in Java using an ArrayList of Objects. Since java already has Stack and Queue classes, you can call your classes myStack and myQueue. Submit your program files with this assignment. Only submit those ending with (.java). Do not submit (.class) files. Be sure to add your name at the top of each file. (a) (10 pts) Implement your own Stack class called myStack in java. Your class should include the following methods: Object pop(): returns and removes the elements on the top of the stack. A NoSuchElementEx- ception' is thrown if pop() is called on an empty stack. Object peek(): returns the element on the top of the stack without removing it. A NoSuchEle- mentException' is thrown if peek() is called on an empty stack push(Object: element): pushes the element onto the stack boolean isEmpty(): returns true if no elements are present in the stack, else returns false. int size(): returns the number of items in the stack

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!