Question: Given this stack: var books = new Stack ( ) ; books.push ( To Kill a Mockingbird ) ; books.push ( Catcher in

Given this stack:
var books = new Stack();
books.push("To Kill a Mockingbird");
books.push("Catcher in the Rye");
books.push("Nineteen Eighty-Four");
Which statement gets the element with a value of "Nineteen Eight-Four" from the stack and removes it from the stack?
Question 23Answer
a.
String nextBook = books.poll();
b.
String nextBook = books.pop();
c.
String nextBook = books.get(2);
d.
String nextBook = books.peek();

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!