Question: Given a piece of JAVA code below. Answer the questions that follows. 1. Stack s = new Stack (); 2. s.push(CS101); 3. s.push(CS102) 4.

Given a piece of JAVA code below. Answer the questions that follows.

Given a piece of JAVA code below. Answer the questions that follows. 1. Stack s = new Stack (); 2. s.push("CS101"); 3. s.push("CS102") 4. String xs.top(); 5. s.push(x); 6. s.push("CS201"); 7. s.push("CS202"); 8. s.push("CS203"); 9. s.pop(); 10. String y = s.top(); 11. s.pop(); 12. System.out.println("Pop is " + s.pop()); 13. s.push(y); 14. System.out.println("x is + x); 15. System.out.println("y is " + s.y()) 1. What is the content of stack after the above code is executed? 2. What are displayed?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 Content of stack after the code is executed After lines 28 the stac... View full answer

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!