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.
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback