Share on Google+Share on Google+

SCJP Module-9 Question-14

Ads
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.

Answer

(4)

Advertisements

Posted on: July 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Ads

Advertisement