logo Practice-It logo

BJP3 Self-Check 14.15: stackQueueUsage3

Language/Type: Java Collections mystery Stacks and Queues
Author: Marty Stepp (on 2013/04/01)

What is the output of the following code?

Queue<Integer> q = new LinkedList<Integer>();
q.add(10);
q.add(4);
System.out.println(q.size());
System.out.println(q.peek());
q.add(6);
System.out.println(q.remove());
q.add(3);
System.out.println(q.remove());
System.out.println(q.peek());
System.out.println(q.remove());
q.add(7);
System.out.println(q.peek());
output

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.