2016년 8월 14일 일요일

OCJP - 1Z0-851(C-3) 공부하자!

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

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

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

그럼 시작.
QUESTION 41
A developer is creating a class Book, that needs to access class Paper.  The Paper class is deployed in a JAR named myLib.jar.  Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)

A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar.
B. The JAR file is located at $JAVA_HOME/jre/lib/ext/myLib.jar..
C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes
/foo/myLib.jar/Paper.class.
D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set that includes
/foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac - cp
/foo/myLib.jar/Paper Book.java.
F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d /foo/myLib.jar
Book.java
G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac - classpath
/foo/myLib.jar Book.java

Answer: BDG


QUESTION 42
Click the Exhibit button.

class Foo {
private int x;
public Foo( int x ){ this.x = x;}
public void setX( int x ) { this.x = x; }
public int getX(){ return x;}
}

public class Gamma {

static Foo fooBar(Foo foo) {
foo = new Foo(100);
return foo;
}    
   
public static void main(String[] args) {
Foo foo = new Foo( 300 );
System.out.println( foo.getX() + "-");

Foo fooFoo = fooBar(foo);
System.out.println(foo.getX() + "-");
System.out.println(fooFoo.getX() + "-");

foo = fooBar( fooFoo);
System.out.println( foo.getX() + "-");
System.out.println(fooFoo.getX());    
}
}

What is the output of the program shown in the exhibit?
: 전시에 표시된 프로그램의 출력물은 무엇인가?

A. 300-100-100-100-100
B. 300-300-100-100-100
C. 300-300-300-100-100
D. 300-300-300-300-100

Answer: B


QUESTION 43
Given classes defined in two different files:

1. package packageA;
2. public class Message {
3.     String getText() {
4.         return "text";
5.     }
6. }

And:

1. package packageB;
2.
3. public class XMLMessage extends packageA.Message {
4.     String getText() {
5.         return "<msg>text</msg>";
6.     }
7.
8.     public static void main(String[] args) {
9.         System.out.println(new XMLMessage().getText());
10.     }
11. }

What is the result of executing XMLMessage.main?
: XMLMessage.main 을 실행한 것은 결과는 무엇인가?

A. text
B. Compilation fails.
C. <msg>text</msg>
D. An exception is thrown at runtime.
 
Answer: C


QUESTION 44
Given:

interface Fish {
}

class Perch implements Fish {
}

class Walleye extends Perch {
}

class Bluegill {
}

public class Fisherman {
public static void main(String[] args) {
Fish f = new Walleye();
Walleye w = new Walleye();
Bluegill b = new Bluegill();
if (f instanceof Perch)
System.out.print("f-p ");
if (w instanceof Fish)
System.out.print("w-f ");
if (b instanceof Fish)
System.out.print("b-f ");    
}
}

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

A. w-f
B. f-p w-f
C. w-f b-f
D. f-p w-f b-f
E. Compilation fails.
F. An exception is thrown at runtime.

Answer: B


QUESTION 45
Given:
 
1. package com.company.application;
2.
3. public class MainClass {
4.     public static void main(String[] args) {
5.     }
6. }

And MainClass exists in the /apps/com/company/application directory.  Assume the CLASSPATH environment variable is set to "." (current directory). Which two java commands entered at the command line will run MainClass? (Choose two.)

A. java MainClass if run from the /apps directory
B. java com.company.application.MainClass if run from the /apps directory
C. java -classpath /apps com.company.application.MainClass if run from any directory
D. java -classpath . MainClass if run from the /apps/com/company/application directory
E. java -classpath /apps/com/company/application:. MainClass if run from the /apps directory
F. java com.company.application.MainClass if run from the /apps/com/company/application directory

Answer: BC


QUESTION 46
Given

class Foo {
static void alpha() {
/* more code here */    
}

    void beta() {
/* more code here */    
}
}

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

A. Foo.beta() is a valid invocation of beta().
B. Foo.alpha() is a valid invocation of alpha().
C. Method beta() can directly call method alpha().
D. Method alpha() can directly call method beta().

Answer: BC


QUESTION 47
Given:

1. public class TestSeven extends Thread {
2.     private static int x;
3.     public synchronized void doThings() {
4.         int current = x;
5.         current++;
6.         x = current;
7.     }
8.     public void run() {
9.         doThings();
10.     }
11. }

Which statement is true?
: 사실인 문장은?

A. Compilation fails.
B. An exception is thrown at runtime.
C. Synchronizing the run() method would make the class thread-safe.
D. The data in variable x are protected from concurrent access problems.
E. Declaring the doThings() method as static would make the class thread-safe.
F. Wrapping the statements within doThings() in a synchronized(new Object()) { } block would make the class thread-safe.

Answer: E


QUESTION 48
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:

1. import java.io.*;
2. public class Maker {
3.     public static void main(String[] args) {
4.         File dir = new File("dir");
5.         File f = new File(dir, "f");
6.     }
7. }

Which statement is true?
: 사실인 문장은?

A. Compilation fails.
B. Nothing is added to the file system.
C. Only a new file is created on the file system.
D. Only a new directory is created on the file system.
E. Both a new file and a new directory are created on the file system.

Answer: B


QUESTION 49
Given:

 NumberFormat nf = NumberFormat.getInstance();
 nf.setMaximumFractionDigits(4);
 nf.setMinimumFractionDigits(2);
 String a = nf.format(3.1415926);
 String b = nf.format(2);

Which two statements are true about the result if the default locale is Locale.US? (Choose two.)
: 디폴트 지역이 Locale.US 일 경우 결과에 대해서 사실인 2 문장은? (2개를 고르시오.)

A. The value of b is 2.
B. The value of a is 3.14.
C. The value of b is 2.00.
D. The value of a is 3.141.
E. The value of a is 3.1415.
F. The value of a is 3.1416.
G. The value of b is 2.0000.

Answer: CF


QUESTION 50
Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.)
: java.io.Serializable 인터페이스 사용의 사실에 관한 3가지 문장은? (3개를 고르시오.)
 
A. Objects from classes that use aggregation cannot be serialized.
B. An object serialized on one JVM can be successfully deserialized on a different JVM.
C. The values in fields with the volatile modifier will NOT survive serialization and deserialization.
D. The values in fields with the transient modifier will NOT survive serialization and deserialization.
E. It is legal to serialize an object of a type that has a supertype that does NOT implement java.io.Serializable.

Answer: BDE


QUESTION 51
Given:

12. String csv = "Sue,5,true,3";
13. Scanner scanner = new Scanner( csv );
14. scanner.useDelimiter(",");
15. int age = scanner.nextInt();
 
What is the result?
: 결과는 무엇인가?

A. Compilation fails.
B. After line 15, the value of age is 5.
C. After line 15, the value of age is 3.
D. An exception is thrown at runtime.

Answer: D


QUESTION 52
Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console? (Choose two.)
: c 를 java.io.Console 개체에 대한 유효한 참조라고 한다면, 콘솔에서 한 줄의 텍스트를 읽을 수 있는 두 개의 코드 조각은? (2개를 고르시오.)

A. String s = c.readLine();
B. char[] c = c.readLine();
C. String s = c.readConsole();
D. char[] c = c.readConsole();
E. String s = c.readLine("%s", "name ");
F. char[] c = c.readLine("%s", "name ");

Answer: AE


QUESTION 53
Given:

11. String test = "a1b2c3";
12. String[] tokens = test.split("\\d");
13. for(String s: tokens) System.out.print(s + " ");  

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

A. a b c
B. 1 2 3
C. a1b2c3
D. a1 b2 c3
E. Compilation fails.
F. The code runs with no output.
G. An exception is thrown at runtime.

Answer: A


QUESTION 54
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.setTime( (60 * 60 * 24) + d.getTime());
B. 35. DateFormat df = DateFormat.getDateInstance();
   42. d.setTime( (1000 * 60 * 60 * 24) + d.getTime());
C. 35. DateFormat df = DateFormat.getDateFormat();
   42. d.setLocalTime( (1000*60*60*24) + d.getLocalTime());
D. 35. DateFormat df = DateFormat.getDateInstance();
   42. d.setLocalTime( (60 * 60 * 24) + d.getLocalTime());  
 
Answer: B


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. Compilation fails.
H. An exception is thrown at runtime.

Answer: C


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

Answer: E


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.

Answer: B


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 exception is thrown at runtime.

Answer: C


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. foofoofoofoofoo
B. foobarfoobarbar
C. foobarfoofoofoo
D. foobarfoobarfoo
E. barbarbarbarbar
F. foofoofoobarbar
G. foofoofoobarfoo

Answer: D


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.
B. Exactly one class does NOT compile.
C. Exactly two classes do NOT compile.
D. Exactly four classes do NOT compile.
E. Exactly three classes do NOT compile.

Answer: C


이해가 안되는 문제가 있다면 글 남겨주세요. 저도 JAVA 공부하면서 같이 해결해요~
Today.
extensive
aj.형용사 아주 넓은, 대규모의

kidney
n.명사 신장, 콩팥

receiver
n.명사 수화기

presentation
n.명사 제출, 제시; 수여, 증정

then again
그렇지 않고 또, 또 한편으로는

댓글 없음:

댓글 쓰기

대항해시대 조선 랭작

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