Consider the code snippet shown below: Stack<String> words1 = new Stack<String>() ;
Stack<String> words2 = new Stack<String>() ;
Words1.push("abc") ;
Words1.push("def") ;
Words1.push("ghi") ;
While (!words1.empty() )
{
Words2.push(words1.pop() ) ;
}
While (!words2.empty() )
{
System.out.print(words2.pop() ) ;
}
What will be printed when this code is executed?
A) abcdefghi
B) ghiabcdef
C) abcghidef
D) defghiabc
Correct Answer:
Verified
Q76: You need to access values using a
Q77: You need to access values by their
Q78: Consider the following code snippet:
Map<String, Integer> scores;
If
Q79: Assume that you have declared a map
Q80: Which of the following algorithms would be
Q82: You need to write a program to
Q83: Assume that you have declared a stack
Q84: Which of the following statements about stacks
Q85: Assume that you have declared a stack
Q86: You intend to use a hash set
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents