반응형
자격증/OCJP_ExamC2018. 7. 26. 19:14QUESTION 59

QUESTION 59 Given: public class Base { public static final String FOO = "foo"; public static void main(String[] args) { Base b = new Base(); Sub s = new Sub(); System.out.print(Base.FOO); System.out.print(Sub.FOO); System.out.print(b.FOO); System.out.print(s.FOO); System.out.print(((Base) s).FOO); } } class Sub extends Base { public static final String FOO = "bar"; } What is the result? A. foofo..

자격증/OCJP_ExamC2018. 7. 26. 19:11QUESTION 58

QUESTION 58 Given: public static Iterator reverse(List list) { Collections.reverse(list); return list.iterator();} public static void main(String[] args) { List list = new ArrayList(); list.add("1"); list.add("2"); list.add("3"); for (Object obj: reverse(list)) System.out.print(obj + ", "); } What is the result? A. 3, 2, 1, B. 1, 2, 3, C. Compilation fails. D. The code runs with no output. E. An..

자격증/OCJP_ExamC2018. 7. 26. 19:05QUESTION 57

QUESTION 57 Given: public static Collection get() { Collection sorted = new LinkedList(); sorted.add("B"); sorted.add("C"); sorted.add("A"); return sorted;} public static void main(String[] args) { for (Object obj: get()) { System.out.print(obj + ", "); }} What is the result? A. A, B, C, B. B, C, A, C. Compilation fails. D. The code runs with no output. E. An exception is thrown at runtime. Solu..

자격증/OCJP_ExamC2018. 7. 26. 18:37QUESTION 56

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 문에서 ..

자격증/OCJP_ExamC2018. 7. 26. 18:19QUESTION 55

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..

자격증/OCJP_ExamC2018. 7. 26. 17:56QUESTION 54

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..

반응형
image