GSSP-JAVA · Question #154
Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. import java.util.*; public class DemoSet{ public static void main(String[] args){ TreeSet<String> ts = new…
Sign in or unlock GSSP-JAVA to reveal the answer and full explanation for question #154. The question stem and answer options stay visible for context.
Question
Mark works as a Programmer for InfoTech Inc. He develops the following code snippet. import java.util.*; public class DemoSet{ public static void main(String[] args){ TreeSet<String> ts = new TreeSet<String>(); ts.add("Sunday"); ts.add("Friday"); ts.add("Wednesday"); ts.add("Sunday"); ts.add("Monday"); Iterator it = ts.iterator(); while(it.hasNext()){ System.out.print(it.next() + " "); } } } What will be the output when he tries to execute the given code snippet?
Options
- AWednesday Sunday Monday Friday
- BAn exception will be thrown at runtime.
- CFriday Monday Sunday Wednesday
- DSunday Monday Wednesday Friday
Unlock GSSP-JAVA to see the answer
You've previewed enough free GSSP-JAVA questions. Unlock GSSP-JAVA for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.