The Sample code given below test you understanding about the Collection Interface, ArrayList class and HashSet class of Collection framework.
The Sample code given below test you understanding about the Collection Interface, ArrayList class and HashSet class of Collection framework.Given below the sample code :
import java.util.*
public class Demo{
enum test{FIRST,SECOND,THIRD}
public static void main(String args[])
{
Collection myCol=new ArrayList();
myCol.add(test.THIRD);
myCol.add(test.THIRD);
myCol.add(test.THIRD);
myCol.add(test.SECOND);
myCol.add(test.SECOND);
myCol.add(test.ONE);
Set myset=new HashSet(mycol)
}
Which statement given below is correct for the code above ?
1.The set contains all 6 elements of collection in the given order.
2.The set contains only 3 elements of collection in the given order.
3.The set contains all 6 elements of collection but not in the given order.
4.The set contains only 3 elements of collection but not in the given order.
(4)