반응형
자격증/OCJP_ExamC2018. 7. 26. 19:31QUESTION 60

QUESTION 60 Given: 1. public interface A { public void m1(); } 2. 3. class B implements A { } 4. class C implements A { public void m1() { } } 5. class D implements A { public void m1(int x) { } } 6. abstract class E implements A { } 7. abstract class F implements A { public void m1() { } } 8. abstract class G implements A { public void m1(int x) { } } What is the result? A. Compilation succeeds..

자격증/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..

반응형
image