Question: Consider the following segment of code. When this segment gets executed, the output is: Stack s = new Stack(); s.push(P); s.pop(); s.push(Q); s.push(R); s.peek(); System.out.println(s.toString());
Consider the following segment of code. When this segment gets executed, the output is:
Stack s = new Stack(); s.push("P"); s.pop(); s.push("Q"); s.push("R"); s.peek(); System.out.println(s.toString()); Select one:
[P, R, R]
[Q, R, R]
[R, R, Q]
[Q, R]
[P, Q, R]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
