반응형
자격증/OCJP_ExamB2018. 7. 13. 19:55QUESTION 48

QUESTION 48 Given: 1. public class TestString3 { 2. public static void main(String[] args) { 3. // insert code here 4. 5. System.out.println(s); 6. } 7. } Which two code fragments, inserted independently at line 3, generate the output 4247? (Choose two.) A. String s = "123456789"; s = (s-"123").replace(1,3,"24") - "89"; B. StringBuffer s = new StringBuffer("123456789"); s.delete(0,3).replace(1,3..

자격증/OCJP_ExamB2018. 7. 13. 19:41QUESTION 47

QUESTION 47 Given: 11. public static void main(String[] args) { 12. Integer i = new Integer(1) + new Integer(2); 13. switch(i) { 14. case 3: System.out.println("three"); break; 15. default: System.out.println("other"); break; 16. } 17. } What is the result? A. three B. other C. An exception is thrown at runtime. D. Compilation fails because of an error on line 12. E. Compilation fails because of..

자격증/OCJP_ExamB2018. 7. 13. 19:17QUESTION 46

QUESTION 46 Given: public class Foo { static int[] a; static { a[0]=2; } public static void main( String[] args ) {} } Which exception or error will be thrown when a programmer attempts to run this code? A. java.lang.StackOverflowError B. java.lang.IllegalStateException C. java.lang.ExceptionInInitializerError D. java.lang.ArrayIndexOutOfBoundsExceptionSolution : C plus imformation Exception in ..

자격증/OCJP_ExamB2018. 7. 13. 19:14QUESTION 45

QUESTION 45 Given: static class A { void process() throws Exception { throw new Exception(); }} static class B extends A { void process() { System.out.println("B"); }} public static void main(String[] args) { new B().process(); } What is the result? A. B B. The code runs with no output. C. Compilation fails because of an error in line 12. D. Compilation fails because of an error in line 15. E. C..

자격증/OCJP_ExamB2018. 7. 13. 19:03QUESTION 44

QUESTION 44 Given: 1. class TestException extends Exception { } 2. class A { 3. public String sayHello(String name) throws TestException { 4. if(name == null) throw new TestException(); 5. return "Hello " + name; 6. } 7. } 8. public class TestA { 9. public static void main(String[] args) { 10. new A().sayHello("Aiko"); 11. } 12. } Which statement is true? A. Compilation succeeds. B. Class A does..

자격증/OCJP_ExamB2018. 7. 13. 18:09QUESTION 43

QUESTION 43 Given: static void test() throws Error { if (true) throw new AssertionError(); System.out.print("test "); } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print("exception "); } System.out.print("end "); } } What is the result? A. end B. Compilation fails. C. exception end D. exception test end E. A Throwable is thrown by main. F. An Except..

반응형
image