Solved

Consider the Code Snippet Shown Below: Stack<String> Words1 = New

Question 16

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions