-
What is the output of below code snippet?
import java.util.*;
public class HashSet_Example
{
public static void main(String[] args)
{
Set setobj = new HashSet();
setobj.add(new Long(20));
setobj.add(new Integer(30));
for(Object object : setobj)
{
System.out.println("test - "+object);
}
}
}
-
- test - 20
- test - 30
- test - 20
test - 30 - test
- None of these
Correct Option: C
Integer and Long are two different data types and different objects. So they will be treated as unique elements and not overridden.