-
What is the output of this program?
import java.util.*;
public class HashSet_Example
{
public static void main(String args[])
{
HashSet object = new HashSet();
object.add("I");
object.add("L");
object.add("U");
System.out.println(object + " " + object.size());
}
}
-
- [U, I, L]
- [I, L, U] 3
- [I, L, U]
- [U, I, L] 3
- None of these
Correct Option: D
HashSet obj creates an hash object which implements Set interface, object.size() gives the number of elements stored in the object object which in this case is 3.