별의 공부 블로그 🧑🏻‍💻

🗒️ Certificate/OCAJP (38)

728x90
  1. 2022.01.14 [1Z0-808][OCAJP] Dump 문제 91~100

    [1Z0-808][OCAJP] Dump 문제 91~100 문제 91 Given : public class App { public static void main(String[] args) { Boolean[] bool = new Boolean[2]; bool[0] = new Boolean(Boolean.parseBoolean("true")); bool[1] = new Boolean(null); System.out.println(bool[0] + " " + bool[1]); } } Q. What is the result? A true null B Compilation fails C true false D A NullPointerException is thrown at runtime 정답 C 해설/결과 Boo..

  2. 2022.01.13 [1Z0-808][OCAJP] Dump 문제 81~90

    [1Z0-808][OCAJP] Dump 문제 81~90 문제 81 Q. Which two class definitions fail to compile? (Choose two.) A abstract class A3 { private static int i; public void doStuff() {} public A3() {} } B final class A1 { public A1() {} } C public class A2 { private static int i; private A2() {} } D class A4 { protected static final int i; private void doStuff() {} } E final abstract class A5 { protected static i..

  3. 2022.01.11 [1Z0-808][OCAJP] Dump 문제 71~80

    [1Z0-808][OCAJP] Dump 문제 71~80 문제 71 Given the code fragment : public static void main(String[] args) { ArrayList myList = new ArrayList(); String[] myArray; try { while (true) { myList.add("My String"); } } catch (RuntimeException re) { System.out.println("Caught a RuntimeException"); } catch (Exception e) { System.out.println("Caught an Exception"); } System.out.println("Ready to use"); } Q. W..

  4. 2022.01.09 [1Z0-808][OCAJP] Dump 문제 61~70

    [1Z0-808][OCAJP] Dump 문제 61~70 문제 61 Given the code fragment : public static void main(String[] args) { String str = " "; str.trim(); System.out.println(str.equals("") + " " + str.isEmpty()); } Q. What is the result? A false true B true true C true false D false false 정답 D 해설/결과 문제 62 Given the following array : int[] intArr = {8, 16, 32, 64, 128}; Q. Which two code fragments, indepdently, print..

  5. 2022.01.07 [1Z0-808][OCAJP] Dump 문제 51~60

    [1Z0-808][OCAJP] Dump 문제 51~60 문제 51 Given : public class Triangle { static double area; int b = 2, h = 3; public static void main(String[] args) { double p, b, h; // line n1 if (area == 0) { b = 3; h = 4; p = 0.5; } area = p * b * h; // line n2 System.out.println("Area is " + area); } } Q. What is the result? A Area is 3.0 B Compilation fails at line n2 C Compilation fails at line n1 D Area is ..

  6. 2022.01.07 [1Z0-808][OCAJP] Dump 문제 41~50

    [1Z0-808][OCAJP] Dump 문제 41~50 문제 41 Given : class Vehicle { int x; Vehicle() { this(10); // line n1 } Vehicle(int x) { this.x = x; } } class Car extends Vehicle { int y; Car() { super(); this(20); // line n2 } Car(int y) { this.y = y; } public String toString() { return super.x + ":" + this.y; } } And given the code fragment : Vehicle y = new Car(); System.out.println(y); Q. What is the result?..

  7. 2022.01.04 [1Z0-808][OCAJP] Dump 문제 31~40

    [1Z0-808][OCAJP] Dump 문제 31~40 문제 31 Given the definitions of the MyString class and the Test class : // (1) MySting.java : package p1; public class MyString { String msg; MyString(String msg) { this.msg = msg; } } // (2) Test.java package p1; public class Test { public static void main(String[] args) { System.out.println("Hello " + new StringBuilder("Java SE 8")); System.out.println("Hello " + ..

  8. 2022.01.02 [1Z0-808][OCAJP] Dump 문제 21~30

    [1Z0-808][OCAJP] Dump 문제 21~30 문제 21 Given the code fragment : public static void main(String[] args) { String[][] arr = {{"A", "B", "C"}, {"D", "E"}}; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { System.out.print(arr[i][j] + " "); if (arr[i][j].equals("B")) { break; } } continue; } } Q. What is the result? A A B C D E B A B D E C A B C D Compilation fails. 정답..

  9. 2022.01.02 [1Z0-808][OCAJP] Dump 문제 11~20

    [1Z0-808][OCAJP] Dump 문제 11~20 문제 11 Given : public static void main(String[] args) { String ta = "A "; ta = ta.concat("B "); String tb = "C "; ta = ta.concat(tb); ta.replace('C', 'D'); ta = ta.concat(tb); System.out.println(ta); } Q. What is the result? A A B C D B A C D C A B C C D A B D E A B D C 정답 C 해설/결과 "ta.replace('C', 'D')" String 형 문자열을 반환만 할 뿐, 변수 ta에 새롭게 할당하지는 않음. 문제 12 Given the cod..

  10. 2021.12.31 [1Z0-808][OCAJP] Dump 문제 1~10 2

    [1Z0-808][OCAJP] Dump 문제 1~10 문제 1 Q. Which statement best describes encapsulation? A Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects. B Encapsulation ensures that classes can be designed so that their methods are inheritable. C Encapsulation ensures that classes can be designed with some fields and methods..

  11. 2021.12.30 [1Z0-851][OCAJP] Dump 문제 1~10

    [1Z0-851][OCAJP] Dump 문제 1~10 문제 1 Given : public class Threads2 implements Runnable { public void run() { System.out.println("run."); throw new RuntimeException("Problem"); } public static void main(String[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println("End of method."); } } Q. Which two can be results? (Choose two.) A java.lang.RuntimeException: Problem B run. j..

  12. 2017.08.15 [1Z0-851E] Question 21~30

    QUESTION 21 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 22 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 23 Select and Place: Correct Answer: Section: (none) Explanation Explanation/Reference: QUESTION 24 Place the correct description of the compiler output on the code fragments to be inserted at lines 4 ..

  13. 2017.08.15 [1Z0-851E] Question 11~20

    QUESTION 11 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 12 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 13 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 14 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: QUESTION 15 Select and..

  14. 2017.08.15 [1Z0-851E] Question 01~10

    QUESTION 1 Select and Place: Correct Answer: Section: All Explanation Explanation/Reference: package alpha; public class Alpha { protected String alpha; public Alpha() { this("A"); } protected Alpha(String a) { alpha = a;} } package beta; public class Beta extends alpha.Alpha { public Beta(String a) { super(a); } } QUESTION 2 Place the Relations on their corresponding Implementation Structures. ..

  15. 2017.08.13 [1Z0-851D] Question 41~50

    QUESTION 41 Given: 1. public class Venus { 2. public static void main(String[] args) { 3. int[] x = { 1, 2, 3 }; 4. int y[] = { 4, 5, 6 }; 5. new Venus().go(x, y); 6. } 7. 8. void go(int[]... z) { 9. for (int[] a : z) 10. System.out.print(a[0]); 11. } 12. } What is the result? A. 1 B. 12 C. 14 D. 123 E. Compilation fails. F. An exception is thrown at runtime. Correct Answer: C Section: All Expla..

  16. 2017.08.13 [1Z0-851D] Question 31~40

    QUESTION 31 Click the Exhibit button. 1. import java.util.*; 2. public class TestSet{ 3. enum Example {ONE, TWO, THREE } 4. public static void main(String[] args) { 5. Collection coll = new ArrayList(); 6. coll.add(Example.THREE); 7. coll.add(Example.THREE); 8. coll.add(Example.THREE); 9. coll.add(Example.TWO); 10. coll.add(Example.TWO); 11. coll.add(Example.ONE); 12. Set set = new HashSet(coll)..

  17. 2017.08.13 [1Z0-851D] Question 21~30

    QUESTION 21 A team of programmers is involved in reviewing a proposed design for a new utility class. After some discussion, they realize that the current design allows other classes to access methods in the utility class that should be accessible only to methods within the utility class itself. What design issue has the team discovered? A. Tight coupling B. Low cohesion C. High cohesion D. Loos..

  18. 2017.08.13 [1Z0-851D] Question 11~20

    QUESTION 11 Given: 1. public class TestOne { 2. public static void main (String[] args) throws Exception { 3. Thread.sleep(3000); 4. System.out.println("sleep"); 5. } 6. } What is the result? A. Compilation fails. B. An exception is thrown at runtime. C. The code executes normally and prints "sleep". D. The code executes normally, but nothing is printed. Correct Answer: C Section: All Explanatio..

  19. 2017.08.13 [1Z0-851D] Question 01~10

    QUESTION 1 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.set..

  20. 2017.08.12 [1Z0-851C] Question 51~60

    QUESTION 51 Given classes defined in two different files: package packageA; public class Message { String getText() { return "text"; } } And: package packageB; public class XMLMessage extends packageA.Message { String getText() { return "text"; } public static void main(String[] args) { System.out.println(new XMLMessage().getText()); } } What is the result of executing XMLMessage.main? A. text B..

  21. 2017.08.12 [1Z0-851C] Question 41~50

    QUESTION 41 Given: public static void main(String[] args) { for (int i = 0; i 6) break; } System.out.println(i); } What is the result? A. 6 B. 7 C. 10 D. 11 E. Compilation fails. F. An exception is thrown at runtime. Correct Answer: E Section: All Explanation Explanation/Reference: i varaible is not visible. QUESTION 42 Given: 11. class X { public void foo() { System.out.print("X "); } } 12. 13...

  22. 2017.08.12 [1Z0-851C] Question 31~40

    QUESTION 31 Given: public class Person { private name; public Person(String name) { this.name = name; } public int hashCode() { return 420; } } Which statement is true? A. The time to find the value from HashMap with a Person key depends on the size of the map. B. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person. C. Inserting a second Person object int..

  23. 2017.08.12 [1Z0-851C] Question 21~30

    QUESTION 21 Given: class Line { public class Point { public int x, y; } public Point getPoint() { return new Point(); } } class Triangle { public Triangle() { // insert code here } } Which code, inserted at line 16, correctly retrieves a local instance of a Point object? A. Point p = Line.getPoint(); B. Line.Point p = Line.getPoint(); C. Point p = (new Line()).getPoint(); D. Line.Point p = (new ..

  24. 2017.08.12 [1Z0-851C] Question 11~20

    QUESTION 11 Given: 1. public class Hi { 2. void m1() { } 3. protected void() m2 { } 04. } 05. 6. class Lois extends Hi { 7. // insert code here 08. } Which four code fragments, inserted independently at line 7, will compile? (Choose four.) A. public void m1() { } B. protected void m1() { } C. private void m1() { } D. void m2() { } E. public void m2() { } F. protected void m2() { } G. private voi..

  25. 2017.08.12 [1Z0-851C] Question 01~10

    QUESTION 1 Given: import java.util.Date; import java.text.DateFormat; 21. DateFormat df; 22. Date date = new Date(); 23. //insert code here 24. String s = df.format(date); Which code fragment, inserted at line 23, allows the code to compile? A. df = new DateFormat(); B. df = Date.getFormat(); C. df = date.getFormat(); D. df = DateFormat.getFormat(); E. df = DateFormat.getInstance(); Correct Answ..

  26. 2017.08.11 [1Z0-851B] Question 51~60

    QUESTION 51 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. Co..

  27. 2017.08.11 [1Z0-851B] Question 41~50

    QUESTION 41 Given: class Snoochy { Boochy booch; public Snoochy() { booch = new Boochy(this); } } class Boochy { Snoochy snooch; public Boochy(Snoochy s) { snooch = s; } } And the statements: 21. public static void main(String[] args) { 22. Snoochy snoog = new Snoochy(); 23. snoog = null; 24. // more code here 25. } Which statement is true about the objects referenced by snoog, snooch, and booch..

  28. 2017.08.11 [1Z0-851B] Question 31~40

    QUESTION 31 Click the Exhibit button. Given the fully-qualified class names: com.foo.bar.Dog com.foo.bar.blatz.Book com.bar.Car com.bar.blatz.Sun Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JVM? Exhibit: A. Jar A B. Jar B C. Jar C D. Jar D E. Jar E Correct Answer: A Section: All Explanation Explanation/Reference: ..

  29. 2017.08.11 [1Z0-851B] Question 21~30

    QUESTION 21 Given: 1. public class TestFive { 2. private int x; 3. 4. public void foo() { 5. int current = x; 6. x = current + 1; 7. } 8. 9. public void go() { 10. for(int i = 0; i < 5; i++) { 11. new Thread() { 12. public void run() { 13. foo(); 14. System.out.print(x + ", "); 15. } 16. }.start(); 17. } 18. } 19. } Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? ..

  30. 2017.08.11 [1Z0-851B] Question 11~20

    QUESTION 11 Given: 3. import java.util.*; 4. public class G1 { 5. public void takeList(List

728x90


📖 Contents 📖