You can use a for-each loop to traverse all elements in a container object that
ID: 3810210 • Letter: Y
Question
You can use a for-each loop to traverse all elements in a container object that implements___ A. Iterator B. Collection C. Iterable D. ArrayList Suppose a list contains {"red", "green", "red", "green"}. What is the list after the following code? list remove ("red"); A. {"red", green "red, "green"} B. {"green", "red", "green"} C. {"green", "green"} D. {"red", green", "green"} Which of the following methods are in the Collection interface? A. clear() B. is Empty() C. size() D. getSize() The poll() method in the Queue interface___. A. retrieves and removes the head of this queue, or null if this queue is empty B. retrieves and removes the head of this queue and throws an exception if this queue is empty C. retrieves, but does not remove, the head of this queue, returning null if this queue is empty D. retrieves, but does not remove, the head of this queue, throwing an exception if this queue is empty The peek() method in the Queue interface___ A. retrieves and removes the head of this queue, or null if this queue is empty B. retrieves and removes the head of this queue and throws an exception if this queue is empty C. retrieves, but does not remove, the head of this queue, returning null if this queue is empty D. retrieves, but does not remove, the head of this queue, throwing an exception if this queue is empty You should use the ArrayList or LinkedList to store duplicate elements. True False Suppose list list1 is [1, 2, 5] and list list2 is [2, 3, 6]. After list1. addAll(list2), list1 is A. [1, 2, 2, 3, 5, 6] B. [1, 2, 3, 5, 6]Explanation / Answer
Please find the answers and explaination as follows:
20) Iterator
21)C{"green","green"}. It removes all the matching values.
22) clear()
23)A. The poll() method in Queue interface retrieves and removes the head of this queue or null if queue is empty.
24) The peek method in Queue interface retrieves, but does not remove, the head of this queue returning null of the queue is empty.
25) True. Both ArrayList and LinkedList stores the duplicate elements.
26) A{1,2,2,3,5,6} It keeps the duplicate elements.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.