카테고리 없음
OCJP Study 10
Soul-Learner
2013. 12. 28. 15:13
OCJP(Java 6) 기출문제 연습 10(91~100)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 91
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?(그림이 포함된 문제이나 사정상 첨부하지 못했음)
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?(그림이 포함된 문제이나 사정상 첨부하지 못했음)
A
설명없음
QUESTION 92
Click the Exhibit button.
Given: ClassA a = new ClassA();
a.methodA();
10. public class ClassA {
11. public void methodA() {
12. ClassB classB = new ClassB();
13. classB.getValue();
14. }
15. }
And:
20. class ClassB {
21. public ClassC classC;
22.
23. public String getValue() {
24. return classC.getValue();
25. }
26. }
And:
30. class ClassC {
31. public String value;
32.
33. public String getValue() {
34. value = "ClassB";
35. return value;
36. }
37. }
What is the result?
Click the Exhibit button.
Given: ClassA a = new ClassA();
a.methodA();
10. public class ClassA {
11. public void methodA() {
12. ClassB classB = new ClassB();
13. classB.getValue();
14. }
15. }
And:
20. class ClassB {
21. public ClassC classC;
22.
23. public String getValue() {
24. return classC.getValue();
25. }
26. }
And:
30. class ClassC {
31. public String value;
32.
33. public String getValue() {
34. value = "ClassB";
35. return value;
36. }
37. }
What is the result?
D
The classC object ins't instantiated.
ZZZ
ZZZ
QUESTION 93
Given:
interface Foo { int bar(); }
public class Sprite {
public int fubar( Foo foo ) { return foo.bar(); }
public void testFoo() {
fubar(
//insert code here 15
);
}
}
Which code, inserted at line 15, allows the class Sprite to compile?
Given:
interface Foo { int bar(); }
public class Sprite {
public int fubar( Foo foo ) { return foo.bar(); }
public void testFoo() {
fubar(
//insert code here 15
);
}
}
Which code, inserted at line 15, allows the class Sprite to compile?
C
설명없음
QUESTION 94
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. }
public static void main(String[] args) {
System.out.println(Title.MR.format("Doe", "John"));
}
What is the result?
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. }
public static void main(String[] args) {
System.out.println(Title.MR.format("Doe", "John"));
}
What is the result?
A
설명없음
QUESTION 95
Given the following six method names:
addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener
How many of these method names follow JavaBean Listener naming rules?
Given the following six method names:
addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener
How many of these method names follow JavaBean Listener naming rules?
B
addMouseListener and removeMouseListener
QUESTION 96
Given:
class Line {
public static class Point {}
}
class Triangle {
public Triangle(){
// insert code here
}
}
Which code, inserted at line 15, creates an instance of the Point class defined in Line?
Given:
class Line {
public static class Point {}
}
class Triangle {
public Triangle(){
// insert code here
}
}
Which code, inserted at line 15, creates an instance of the Point class defined in Line?
B
설명없음
QUESTION 96
Given
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12? (Choose three.)
Given
11. public interface Status {
12. /* insert code here */ int MY_VALUE = 10;
13. }
Which three are valid on line 12? (Choose three.)
A,B,D
설명없음
QUESTION 98
Click the Exhibit button.
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.}
Click the Exhibit button.
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
Error in line 6: "Cannot make a static reference to the non-static field counter"
ZZZ
ZZZ
QUESTION 99
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?
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?
C
설명없음
QUESTION 100
Click the Exhibit button.
Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
class Inner {
private int x;
public void setX( int x ){ this.x = x; }
public int getX(){ return x;}
}
class Outer {
private Inner y;
public void setY( Inner y ){ this.y = y; }
public Inner getY() { return y; }
}
public class Gamma {
public static void main(String[] args) {
Outer o = new Outer();
Inner i = new Inner();
int n = 10;
i.setX(n);
o.setY(i);
// insert code here 29
System.out.println(o.getY().getX());
}
}
Click the Exhibit button.
Which three code fragments, added individually at line 29, produce the output 100? (Choose three.)
class Inner {
private int x;
public void setX( int x ){ this.x = x; }
public int getX(){ return x;}
}
class Outer {
private Inner y;
public void setY( Inner y ){ this.y = y; }
public Inner getY() { return y; }
}
public class Gamma {
public static void main(String[] args) {
Outer o = new Outer();
Inner i = new Inner();
int n = 10;
i.setX(n);
o.setY(i);
// insert code here 29
System.out.println(o.getY().getX());
}
}
B,C,F
설명없음