Question: Predict the output import java.util. * ; public class TryStack { public static void main ( String [ ] args ) { Stack s 1

Predict the output
import java.util.*;
public class TryStack
{
public static void main(String[] args)
{
Stack s1=new Stack();
s1.push("Abc");
s1.push("def");
s1.push("pqr");
s1.push("45");
s1.add(2,"xyz");
System.out.print(s1);
}
}
a.
[Abc, def, xyz, pqr,45]
b.
error
c.
[Abc, xyz, pqr,45, def]
d.
[Abc, xyz, pqr,45]

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 Programming Questions!