A

Admin • 828.03K Points
Coach

Q. What will be the output of the following code

Code:
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class SortSet {
public static void main(String…a)
{
Collection<Integer> collection = new HashSet<Integer>();
collection.add(3);
collection.add(1);
collection.add(2); {

Set<Integer> treeSet=new TreeSet<Integer>(collection);
System.out.println(treeSet);

}
}
}
  • (A) [1, 2, 3]
  • (B) Runtime exception
  • (C) [3, 2, 1]
  • (D) None of the above
  • Correct Answer - Option(A)
  • Views: 11
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.