Multiple Choice
Select an appropriate expression to complete the method below, which is designed to print the element at the bottom of a Stack collection. The contents of the original stack are restored before the method terminates. It is safe to assume that the original stack contains at least one element. public static void printBottom(Stack<String> theStack)
{
Stack<String> anotherStack = new Stack<String>() ;
While (theStack.size() > 0)
{
AnotherStack.push(theStack.pop() ) ;
}
____________________________
While (anotherStack.size() > 0)
{
TheStack.push(anotherStack.pop() ) ;
}
}
A) System.out.println(theStack.pop() ) ;
B) System.out.println(theStack.peek() ) ;
C) System.out.println(anotherStack.peek() ) ;
D) System.out.println(anotherStack.pop() ) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q17: Assume you have created a linked list
Q18: What operation is least efficient in a
Q19: Which of the following statements about the
Q20: Which data structure would best be used
Q21: A collection without an intrinsic order is
Q23: Which of the following statements about a
Q24: Select an appropriate expression to complete the
Q25: Consider the following code snippet: Stack<String> stringStack
Q26: Consider the following code snippet: LinkedList<String> words
Q27: Which of the following statements about manipulating