What is the result of compilation and execution of the following program:

import java.util.*;

class Main {
    public static void main(String[] args) {
        List<?> list = new ArrayList<String>();
When you have an object of generic class defined with a wildcard <?>, you can't call methods, that take arguments of type-parameter. The only exception from this rule is passing the value null.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes