Ask Question

What is the output of the following code? Recall that stacks and queues print in an [a, b, c] format from bottom/front to top/back. Stack s = new Stack (); Queue q = new LinkedList (); s. push ("how"); s. push ("are"); s. push ("you"); while (! s. isEmpty ()) { q. add (s. pop ()); } System. out. println (q);

+1
Answers (1)
  1. 13 November, 07:28
    0
    [you, are, how]

    Explanation:

    The output for given code will be [you, are, how]. Pop gives the mist recently added element in the stack so order is reversed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is the output of the following code? Recall that stacks and queues print in an [a, b, c] format from bottom/front to top/back. Stack s ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers