2016년 8월 14일 일요일

OCJP - 1Z0-851(B-2) 공부하자!

Name : OCJP Study
Category : Software
Purpose : JAVA 공부하면서 OCJP 가 합격이 되도록 비나이다.
compatibility : ...
Etc : eclipse

공부한 거는 Post 하자.!!!

JAVA도 공부하면서 OCJP 도 한번에 합격하시기를...
지금 이글을 읽을 정도로 자신의 시간을 투자하는 사람이라면 합격은 당연한것인가. 흠.

그럼 시작.
QUESTION 21
Given:

abstract public class Employee {
     protected abstract double getSalesAmount();
     public double getCommision() {
return getSalesAmount() * 0.15;
}
}
class Sales extends Employee {
 17. //    insert method here
}

Which two methods, inserted independently at line 17, correctly complete the Sales class? (Choose two.)
: 17라인에 독립적으로 삽입하여, Sales 클래스를 올바르게 컴파일하는 두 개의 메소드는? (2개를 고르시오.)

A. double getSalesAmount() { return 1230.45; }
B. public double getSalesAmount() { return 1230.45; }
C. private double getSalesAmount() { return 1230.45; }
D. protected double getSalesAmount() { return 1230.45; }

Answer: BD


QUESTION 22
Given:

1. class X {
2.     X() { System.out.print(1); }
3.     X(int x) {
4.         this(); System.out.print(2);
5.     }
6. }
7. public class Y extends X {
8.     Y() { super(6); System.out.print(3); }
9.     Y(int y) {
10.         this(); System.out.println(4);
11.     }
12.     public static void main(String[] a) { new Y(5); }
13. }

What is the result?
: 결과는 무엇인가?

A. 13
B. 134
C. 1234
D. 2134
E. 2143
F. 4321

Answer: C


QUESTION 23
Given:

package com.sun.scjp;
public class Geodetics {
     public static final double DIAMETER = 12756.32; // kilometers
}

Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.)
: Geodetics 클래스의 DIAMETER 멤버에 올바르게 접근하는 2개는? (2개를 고르시오.)

A. import com.sun.scjp.Geodetics;
public class TerraCarta {
public double halfway()
{ return Geodetics.DIAMETER/2.0; }
B. import static com.sun.scjp.Geodetics;
public class TerraCarta{
public double halfway()
{ return DIAMETER/2.0; } }
C. import static com.sun.scjp.Geodetics.*;
public class TerraCarta {
public double halfway()
{ return DIAMETER/2.0; } }
D. package com.sun.scjp;
public class TerraCarta {
public double halfway()
{ return DIAMETER/2.0; } }

Answer: AC


QUESTION 24
Given:

1. public class A {
2.     public void doit() {
3.     }
4.     public String doit() {
5.         return "a";
6.     }
7.     public double doit(int x) {
8.         return 1.0;
9.     }
10. }

What is the result?
: 결과는 무엇인가?

A. An exception is thrown at runtime.
B. Compilation fails because of an error in line 7.
C. Compilation fails because of an error in line 4.
D. Compilation succeeds and no runtime errors with class A occur.

Answer: C


QUESTION 25
Given:

35. String #name = "Jane Doe";
36. int $age = 24;
37. Double _height = 123.5;
38. double ~temp = 37.5;

Which two statements are true? (Choose two.)
: 사실인 두 문장은? (2개를 고르시오.)

A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.

Answer: AD


QUESTION 26
Given:

1. public class ClassA {
2.     public void methodA() {
3.         ClassB classB = new ClassB();
4.         classB.getValue();
5.     }
6. }
7.
8. class ClassB {
9.     public ClassC classC;
10.     public String getValue() {
11.         return classC.getValue();
12.     }
13. }
14.
15. class ClassC {
16.     public String value;
17.     public String getValue() {
18.         value = "ClassC";
19.         return value;
20.     }
21. }

and:

ClassA a = new ClassA();
a.methodA();

What is the result?
: 결과는 무엇인가?

A. Compilation fails.
B. ClassC is displayed.
C. The code runs with no output.
D. An exception is thrown at runtime.

Answer: D


QUESTION 27
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?
: 어느 것들의 클래스가 컴파일러 및 JVM에 의해 사용될 수있는 JAR 파일에 대한 올바른 디렉토리 구조를 나타낸 그래프는?

A. Jar A
B. Jar B
C. Jar C
D. Jar D
E. Jar E

Answer: A


QUESTION 28
Given:

10. interface Foo { int bar(); }
11. public class Sprite {
12.     public int fubar( Foo foo ) { return foo.bar(); }
13.     public void testFoo() {
14.         fubar(
15.         //insert code here
16.         );
17.     }
18. }

Which code, inserted at line 15, allows the class Sprite to compile?
: 15라인에 삽입하여, Sprite 클래스가 컴파일이 되는 코드는 어느 것인가?

A. Foo { public int bar() { return 1; }
B. new Foo { public int bar() { return 1; }
C. new Foo() { public int bar() { return 1; }
D. new class Foo { public int bar() { return 1; }

Answer: C


QUESTION 29
Given:

11. public enum Title {
12.     MR("Mr."), MRS("Mrs."), MS("Ms.");
13.     private final String title;
14.     private Title(String t) { title = t; }
15.     public String format(String last, String first) {
16.         return title + " " + first + " " + last;
17.     }
18. }
19.
20. public static void main(String[] args) {
21.     System.out.println(Title.MR.format("Doe", "John"));
22. }

What is the result?
: 결과는 무엇인가?

A. Mr. John Doe
B. An exception is thrown at runtime.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 20.

Answer: A


QUESTION 30
Given the following six method names:

addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener

How many of these method names follow JavaBean Listener naming rules?
: JavaBean Listener 네이밍 룰을 따르는 메소드 이름들은 몇 개인가?

A. 1
B. 2
C. 3
D. 4
E. 5

Answer: B


QUESTION 31
Given:

09. class Line {
10.     public static class Point {}
11. }
12.
13. class Triangle {
14.     public Triangle(){
15.     //  insert code here
16.     }
17. }

Which code, inserted at line 15, creates an instance of the Point class defined in Line?
: 15라인에 삽입하여, Line 클래스에 정의된 Point 클래스의 인스턴스를 생성하는 코드는 어느 것인가?

A. Point p = new Point();
B. Line.Point p = new Line.Point();
C. The Point class cannot be instatiated at line 15.
D. Line l = new Line() ; l.Point p = new l.Point();

Answer: B


QUESTION 32
Given

11. public interface Status {
12.    /* insert code here */ int MY_VALUE = 10;
13. }

Which three are valid on line 12? (Choose three.)
: 12라인에 유효할 3개는? (3개를 고르시오)

A. final
B. static
C. native
D. public
E. private
F. abstract
G. protected

Answer: ABD


QUESTION 33
Given this code from Class B:

25. A a1 = new A();
26. A a2 = new A();
27. A a3 = new A();
28. System.out.println(A.getInstanceCount());

What is the result?
: 결과는 무엇인가?

1. public class A{
2.    
3.     private int counter = 0;
4.    
5.     public static int getInstanceCount() {
6.         return counter;
7.     }
8.    
9.     public A() {
10.         counter++;
11.     }
12.    
13. }

A. Compilation of class A fails.
B. Line 28 prints the value 3 to System.out.
C. Line 28 prints the value 1 to System.out.
D. A runtime error occurs when line 25 executes.
E. Compilation fails because of an error on line 28.

Answer: A


QUESTION 34
Given classes defined in two different files:

1. package util;
2. public class BitUtils {
3.     public static void process(byte[] b) { /* more code here */ }
4. }

1. package app;
2. public class SomeApp {
3.     public static void main(String[] args) {
4.         byte[] bytes = new byte[256];
5. //        insert code here
6.     }
7. }

What is required at line 5 in class SomeApp to use the process method of BitUtils?
: SomeApp 클래스의 5라인에는 BitUtils의 process 메소드를 사용하기 위해 무엇이 필요한가?

A. process(bytes);
B. BitUtils.process(bytes);
C. util.BitUtils.process(bytes);
D. SomeApp cannot use methods in BitUtils.
E. import util.BitUtils.*; process(bytes);

Answer: C


QUESTION 35

Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
: 29라인에 개별적으로 추가하여, 100의 출력이 나오게 하는 코드 조각 3개는?

10. class Inner {
11.     private int x;
12.     public void setX( int x ){ this.x = x; }
13.     public int getX(){ return x;}
14. }
15.
16. class Outer {
17.     private Inner y;
18.     public void setY( Inner y ){ this.y = y; }
19.     public Inner getY() { return y; }
20. }
21.
22. public class Gamma {
23.     public static void main(String[] args) {
24.         Outer o = new Outer();
25.         Inner i = new Inner();
26.         int n = 10;
27.         i.setX(n);
28.         o.setY(i);
29.         // insert code here 29
30.         System.out.println(o.getY().getX());
31.        
32.     }
33. }

A. n = 100;
B. i.setX( 100 );
C. o.getY().setX( 100 );
D. i = new Inner(); i.setX( 100 );
E. o.setY( i ); i = new Inner(); i.setX( 100 );
F. i = new Inner(); i.setX( 100 ); o.setY( i );

Answer: BCF


QUESTION 36
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 immediately after line 23 executes?
: snoog, snooch에 의해 참조된 오브젝트들와 booch가 23라인에서 곧 실행될 것에 관해서 사실인 문장은 어느 것이냐?

A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage collection.
C. Only the object referenced by snoog is eligible for garbage collection.
D. Only the object referenced by snooch is eligible for garbage collection.
E. The objects referenced by snooch and booch are eligible for garbage collection.
: snooch 와 booch 에 의해 참조된 오브젝트들은 garbage collection을 받을 수 잇다.

Answer: E


QUESTION 37
Given:

03. interface Animal { void makeNoise(); }
04. class Horse implements Animal {
05.     Long weight = 1200L;
06.     public void makeNoise() { System.out.println("whinny"); }
07. }
08. public class Icelandic extends Horse {
09.     public void makeNoise() { System.out.println("vinny"); }
10.     public static void main(String[] args) {
11.         Icelandic i1 = new Icelandic();
12.         Icelandic i2 = new Icelandic();
13.         Icelandic i3 = new Icelandic();
14.         i3 = i1; i1 = i2; i2 = null; i3 = i1;
15.     }
16. }

When line 15 is reached, how many objects are eligible for the garbage collector?
: 15라인까지 가면, 몇 개의 오브젝트가 garbage collector를 받는가?

A. 0
B. 1
C. 2
D. 3
E. 4
F. 6

Answer: E


QUESTION 38
Given:

01. public static void test(String str) {
02.     int check = 4;
03.     if (check = str.length()) {
04.         System.out.print(str.charAt(check -= 1) +", ");
05.     } else {
06.         System.out.print(str.charAt(0) + ", ");
07.     }
08. }

and the invocation:

test("four");
test("tee");
test("to");

What is the result?
: 결과는 무엇인가?

A. r, t, t,
B. r, e, o,
C. Compilation fails.
D. An exception is thrown at runtime.

Answer: C


QUESTION 39
Given classes defined in two different files:

1. package util;
2. public class BitUtils {
3.     private static void process(byte[] b) {}
4. }

and

1. package app;
2. public class SomeApp {
3.     public static void main(String[] args) {
4.         byte[] bytes = new byte[256];
5.         // insert code here
6.     }
7. }

What is required at line 5 in class SomeApp to use the process method of BitUtils?
: SomeApp 클래스의 5라인에는 BitUtils의 process 메소드를 사용하기 위해 무엇이 필요한가?

A. process(bytes);
B. BitUtils.process(bytes);
C. app.BitUtils.process(bytes);
D. util.BitUtils.process(bytes);
E. import util.BitUtils.*; process(bytes);
F. SomeApp cannot use the process method in BitUtils.

Answer: F


QUESTION 40
Given:

1. public class Pass2 {
2.     public void main(String [] args) {
3.         int x = 6;
4.         Pass2 p = new Pass2();
5.         p.doStuff(x);
6.         System.out.print(" main x = " + x);
7.     }
8.
9.     void doStuff(int x) {
10.         System.out.print(" doStuff x = " + x++);
11.     }
12. }

And the command-line invocations:

javac Pass2.java
java Pass2 5

What is the result?
: 결과는 무엇인가?

A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 6 main x = 7
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7

Answer: B

이해가 안되는 문제가 있다면 글 남겨주세요. 저도 JAVA 공부하면서 같이 해결해요~
Today.
expulsion
n.명사 (어떤 장소에서의) 축출

alcoholic
aj.형용사 술의, 알코올이 든

observer
n.명사 보는 사람, 목격자

verbal
aj.형용사 언어의

stay tuned
동조시키다

댓글 없음:

댓글 쓰기

대항해시대 조선 랭작

숙련도 획득 방법 선박 건조, 선박 강화, 전용함 추가시 숙련도 획득 모두 동일한 공식 적용 획득 숙련도 공식 기본 획득 숙련도 ≒ int{건조일수 × 현재랭크 × (0.525)} 이벤트 & 아이템 사용...