Menu
Question Index
...

Compare the following programs?

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

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


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.

Doubts

Problems

Topic: Java Collection Algorithms

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App