Menu
Question Index
...

What values will hashSet contain at the end of the program?

import java.util.HashSet;

public class HashRetain
{
    public static void main(String Str[])
    {
        HashSet<String> hashSet = new HashSet<String>();
        hashSet.add("A");
        hashSet.add("B");
        hashSet.add("C");
        hashSet.add("D");
        hashSet.add("E");

        HashSet<String> subSet = new HashSet<String>();
        subSet.add("E");
        subSet.add("B");
        subSet.add("A");
        subSet.add("F");
        hashSet.retainAll(subSet);
    }
}


A, B, C, D, E, F
A, B, E
C, D
A, B, E, F
Compilation Error or Runtime Error

Doubts

Problems

Topic: HashSet Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App