-
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..
-
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..
-
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..
-
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..
-
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 ..
-
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?..
-
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 " + ..
-
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. 정답..
-
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..
-
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..
-
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..