Which of the following options could be inserted into (1) without causing compilation error

import java.util.*;

public class Test {
    public static void main(String[] args) {
        List<?> lst = new ArrayList<String>();
        // (1) Insert code here
    }    
}
Explanation
Since lst is List of values of unknown reference type, the only operations allowed are adding null (which is a correct value for all reference types) and reading into Object, as the last one is a parent for all reference types.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести