Which statements, when inserted independently at (1), will guarantee that the following program will print [1, 9]?
import java.util.*; public class Main { public static void main(String[] args) { // (1) INSERT DECLARATION HERE. collection.add(1); collection.add(9); collection.add(1); System.out.println(collection); } }
Select the four correct answers.
(b) and (d)
The methods add()
and retainAll()
, return the value true if the collection was modified during the operation.
The contains()
and containsAll()
methods return a boolean value, but these membership operations never modify the current collection, and the return value indicates the result of the membership test.
The clear()
method does not return a value.