Which code, inserted at line 4, guarantees that this program will output [1, 2]?

Given:
01. import java.util.*;
02. public class Example {
03. public static void main(String[] args) {
04. // insert code here
05. set.add(new Integer(2));
06. set.add(new Integer(1));
07. System.out.println(set);
08. }
09. }
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
A. Set set = new TreeSet();
B. Set set = new HashSet();
C. Set set = new SortedSet();
D. List set = new SortedList();
E. Set set = new LinkedHashSet();

Download Printable PDF. VALID exam to help you PASS.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.