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
Зарегистрируйся сейчас
или Подпишись на будущие тесты