Question Index

Compare the following programs?

import java.util.*;
public class Empty1
    public static void main(String args[])
        List<String> list = Collections.<String>emptyList();

import java.util.*;
public class Empty2
    public static void main(String S[])
        Set<String> set = Collections.<String>emptySet();

Both Empty1 and Empty2 produce same output.
Empty1 and Empty2 produce different output.
Empty2 compiles and runs with out any error, but Empty1 gives compilation error.
Empty1 compiles and runs with out any error, but Empty2 gives compilation error.
Both Empty1 and Empty2 fail to execute.



Topic: Java Collection Algorithms

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App