QUESTION 56 Given: static void test() { try { String x = null; System.out.print(x.toString() + " "); } finally { System.out.print("finally "); }} public static void main(String[] args) { try { test();} catch (Exception ex) { System.out.print("exception "); } } What is the result? A. null B. finally C. null finally D. Compilation fails. E. finally exception Solution : E plus imformation main 문에서 ..
QUESTION 55 Given: import java.util.*; public class Quest { public static void main(String[] args) { String[] colors = {"blue", "red", "green", "yellow", "orange"}; Arrays.sort(colors); int s2 = Arrays.binarySearch(colors, "orange"); int s3 = Arrays.binarySearch(colors, "violet"); System.out.println(s2 + " " + s3); } } What is the result? A. 2 -1 B. 2 -4 C. 2 -5 D. 3 -1 E. 3 -4 F. 3 -5 G. Compil..
QUESTION 54 Given: 33. Date d = new Date(0); 34. String ds = "December 15, 2004"; 35. // insert code here 36. try { 37. d = df.parse(ds); 38. } 39. catch(ParseException e) { 40. System.out.println("Unable to parse " + ds); 41. } 42. // insert code here too What creates the appropriate DateFormat object and adds a day to the Date object? A. 35. DateFormat df = DateFormat.getDateFormat(); 42. d.se..
QUESTION 53 Given: 11. String test = "a1b2c3"; 12. String[] tokens = test.split("\\d"); 13. for(String s: tokens) System.out.print(s + " "); What is the result? A. a b c B. 1 2 3 C. a1b2c3 D. a1 b2 c3 E. Compilation fails. F. The code runs with no output. G. An exception is thrown at runtime. Solution : A
QUESTION 52 Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console? (Choose two.) A. String s = c.readLine(); B. char[] c = c.readLine(); C. String s = c.readConsole(); D. char[] c = c.readConsole(); E. String s = c.readLine("%s", "name "); F. char[] c = c.readLine("%s", "name "); Solution : AE
QUESTION 51 Given: 12. String csv = "Sue,5,true,3"; 13. Scanner scanner = new Scanner( csv ); 14. scanner.useDelimiter(","); 15. int age = scanner.nextInt(); What is the result? A. Compilation fails. B. After line 15, the value of age is 5. C. After line 15, the value of age is 3. D. An exception is thrown at runtime. Answer: D Section: All Explanation/Reference: Exception in thread "main" java...