Solved

Consider the Following Code Snippet: Stack<String> Words1 = New Stack<String>();

Question 37

Multiple Choice

Consider the following code snippet: Stack<String> words1 = new Stack<String>() ;
ArrayList<String> words3 = new ArrayList<String>() ;
Words1.push("abc") ;
Words1.push("def") ;
Words1.push("ghi") ;
While (!words1.empty() )
{
Words3.add(words1.pop() ) ;
}
Int i = words3.size() - 1;
While (i >= 0)
{
System.out.print(words3.remove(i) ) ;
I--;
}
What will this code print when it 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