Question
Without entering it into eclipse, trace the following piece of code. What will it display to the screen? Queue myQ = new LinkedList (); myQ.add(10);
Without entering it into eclipse, trace the following piece of code. What will it display to the screen?
QueuemyQ = new LinkedList (); myQ.add(10); myQ.add(15); myQ.add(3); myQ.add(9); while (!myQ.isEmpty()) { System.out.print(myQ.remove()+" "); } System.out.println();
Without entering it into eclipse, trace the following piece of code. What will it display to the screen?
StackmyS = new Stack (); myS.push(10); myS.push(15); myS.push(3); myS.push(9); while (!myS.isEmpty()) { System.out.print(myS.pop()+" "); } System.out.println();
Imagine you have a program where the digits 0 through 9 are pushed, in order, onto a Stack. Each digit is popped off the Stack in turn and pushed onto a second Stack. Then they are all popped off the second Stack and printed on a single line with a space between each digit. What will the output of this program be?
Write a method reverse that takes an ArrayList of Integers as an argument and returns a new ArrayList of Integers that is the reverse of the original list. For example, if the original list was [9, 7, 4, 6] the method should return [6, 4, 7, 9]. You method must use a Stack to perform this reverse operation.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started