q1, ArrayQueue q2)Iterator iter1 = q1.iterator();while (iter1.hasNext()){int a = iter1.next();if (a > q2.peek() )q2.offer(a);}}}O a. All elements of q1 which are greater than the first...


What is the purpose of the following method? Assume that both q1 and q2 are not empty.<br>public class QueueEx<br>{<br>public static void method1(ArrayQueue<Integer> q1, ArrayQueue<Integer> q2)<br>Iterator<Integer> iter1 = q1.iterator();<br>while (iter1.hasNext())<br>{<br>int a = iter1.next();<br>if (a > q2.peek() )<br>q2.offer(a);<br>}<br>}<br>}<br>O a. All elements of q1 which are greater than the first element of q1 will be added to q2.<br>O B. All elements of q1 which are greater than the corresponding elements of q2 will be added to q2.<br>Oc. All elements of q2 which are greater than the first element of q1 will be added to q1.<br>O d. All elements of q1 which are greater than the first element of q2 will be added to q2.<br>

Extracted text: What is the purpose of the following method? Assume that both q1 and q2 are not empty. public class QueueEx { public static void method1(ArrayQueue q1, ArrayQueue q2) Iterator iter1 = q1.iterator(); while (iter1.hasNext()) { int a = iter1.next(); if (a > q2.peek() ) q2.offer(a); } } } O a. All elements of q1 which are greater than the first element of q1 will be added to q2. O B. All elements of q1 which are greater than the corresponding elements of q2 will be added to q2. Oc. All elements of q2 which are greater than the first element of q1 will be added to q1. O d. All elements of q1 which are greater than the first element of q2 will be added to q2.

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here