Given: import java.util.*; public class City { public static void main(String[] args) { Set set = new LinkedHashSet(); set.add(new String("Chicago")); set.add(new String("Boston")); set.add(new String("Alabama")); set.add(new String("Chicago")); System.out.println(set); } } What will be printed out?
Given: public class Test { public static void main(String[] args) { String s = "foo"; Object o = (Object)s; if (s.equals(o)) { System.out.print("AAA"); } else { System.out.print("BBB"); } if (o.equals(s)) { System.out.print("CCC"); } else { System.out.print("DDD"); } } } What will be printed out?
Given: public class References { static void increment(int[] a) { a[1]++; } public static void main(String[] args) { int[] a = new int[5]; increment(a); System.out.println(a[1]); } } What is the outcome:
Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?
Given: public class Test { public static void main(String[] args) { final StringBuffer a = new StringBuffer(); final StringBuffer b = new StringBuffer(); new Thread() { public void run() { System.out.print(a.append("A")); synchronized(b) { System.out.print(b.append("B")); } } }.start(); new Thread() { public void run() { System.out.print(b.append("C")); synchronized(a) { System.out.print(a.append("D")); } } }.start(); } } What is the output?
Given the following: public class ExamQuestion1 { public static void main(String[] args){ try{ badMethod(); System.out.println("A"); } catch(Exception e){ System.out.println("B"); } finally{ System.out.println("C"); } System.out.println("D"); } 15 static void badMethod(){ throw new Error(); } } What is the result of compiling and executing this code?
Given the following : interface I0{} What lines of code would compile? (Choose two)
Which of the following would compile without error?
Which of the following would be suitable for use as keys in a HashMap? (choose two)
Which of the following would be suitable for use as keys in a HashMap? (choose two)