class Test
{

public static void main(String [] args) throws Exception
{
Vector data = new Vector();
data.add("apple");
data.add("mango");
data.add("papaya");
data.add("cherry");
data.add("banana");
data.add("apple");
System.out.println(getData(data));
}

public static Vector getData(Vector v)
{
return new Vector(new HashSet(v));
}

}

What would be the output?

Options
- Compile Error
- [apple, banana, cherry, mango, papaya]
- [banana, cherry, papaya, apple, mango]
- [banana, cherry, papaya, apple, apple, mango]


CORRECT ANSWER : [banana, cherry, papaya, apple, mango]

Discussion Board
c++,java

I have work in non voice process in medical coding billing in billing

meena 07-30-2017 05:51 AM

HashSet

In this we cannot maintain any order of execution as Hashset does not presever any order and insert the object using hashcode.
All the option for this question are not applicable.

Manish Malaviya 11-20-2014 02:01 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement