Question 1
Consider the Java code given below.
import java.util.*;
public class SetIteratorTest { public static void main(String[] args) { var set1 = new HashSet<String>(); set1.add("Cherry"); set1.add("Banana"); set1.add("Apple"); set1.add("Date");
var set2 = new TreeSet<String>(set1); Iterator<String> it1 = set1.iterator(); Iterator<String> it2 = set2.iterator();
while (it1.hasNext()) { System.out.println(it1.next()); }
while (it2.hasNext()) { System.out.println(it2.next()); } }}Choose the correct option.