Menu
Question Index
...

What will the output of the following program?

import java.util.*;
public class SetTest{
    public static void main(String arg[]){
        Set s = new HashSet();
        s.add("A");
        s.add("B");
        s.add("C");
        s.add("D");
        s.add("E");
        s.add("F");
        s.add("H");
        Collections.unmodifiableSet(s);
        s = Collections.unmodifiableSet(s);
        s.clear();
        System.out.println(s);
    }
}


[D, E, F, A, B, C, H]
[A, B, C, D, E, F, G]
[H, F, E, D, C, B, A]
Compilation Error
Throws Exception

Doubts

Problems

Topic: Java Read-only Collections And Algorithms

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App