Question: public interface Stack { /** * Returns the number of elements in the stack. */ int size(); /** * Tests whether the stack is empty.
public interface Stack{ /** * Returns the number of elements in the stack. */ int size(); /** * Tests whether the stack is empty. */ boolean isEmpty(); /** * Inserts an element at the top of the stack. */ void push(E e); /** * Returns, but does not remove, the element at the top of the stack, or null if the stack is empty. */ E top(); /** * Removes and returns the top element from the stack, or null if the stack is empty. */ E pop(); }
Consider the following sequence of operations on a Stack that begins empty. Give the return value for each line. If it causes an error, then write ERROR.
push("A")
push("B")
pop() // FIRST
top() // SECOND
push("C")
pop() // THIRD
pop() // FOURTH
pop() // FIFTH
Group of answer choices
FIRST
[ Choose ] true false C null A B
SECOND
[ Choose ] true false C null A B
THIRD
[ Choose ] true false C null A B
FOURTH
[ Choose ] true false C null A B
FIFTH
[ Choose ] true false C null A B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
