Question: What is the output of the below code? public static void main ( string [ ] args ) f stack s 1 = new stack

What is the output of the below code?
public static void main (string[] args) f
stack s1= new stack(10);
stack $2= new stack(10);
for (int i=0;i10;i++
s1. push (i++);
s2. push (s1.top ()) ;
s1. pop ();
s2. push (s1.top ());
s1.pop();
s2. push (s1.top ());
s1. pop ();
system.out.println (s1.top ());
system.out.printin (s2.top());
Your answer:
1
3
1
4
2
4
1
2
2
3
Clear answer
 What is the output of the below code? public static void

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!