OCJP(Java 6) 기출문제 연습 9(81~90)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 81
Given:
1. public class TestFive {
2. private int x;
3. public void foo() {
4. int current = x;
5. x = current + 1;
6. }
7. public void go() {
8. for(int i = 0; i < 5; i++) {
9. new Thread() {
10. public void run() {
11. foo();
12. System.out.print(x + ", ");
13. } }.start();
14. } }
15.}
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.)
Given:
1. public class TestFive {
2. private int x;
3. public void foo() {
4. int current = x;
5. x = current + 1;
6. }
7. public void go() {
8. for(int i = 0; i < 5; i++) {
9. new Thread() {
10. public void run() {
11. foo();
12. System.out.print(x + ", ");
13. } }.start();
14. } }
15.}
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ? (Choose two.)
A,D
설명없음
QUESTION 82
Given that t1 is a reference to a live thread, which is true?
Given that t1 is a reference to a live thread, which is true?
E
설명없음
QUESTION 83
Given:
Runnable r = new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t = new Thread(r) {
public void run() {
System.out.print("Dog");
}
};
t.start();
What is the result?
Given:
Runnable r = new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t = new Thread(r) {
public void run() {
System.out.print("Dog");
}
};
t.start();
What is the result?
B
설명없음
QUESTION 84
Given:
1. public class Threads5 {
2. public static void main (String[] args) {
3. new Thread(new Runnable() {
4. public void run() {
5. System.out.print("bar");
6. }}).start();
7. }
8. }
What is the result?
Given:
1. public class Threads5 {
2. public static void main (String[] args) {
3. new Thread(new Runnable() {
4. public void run() {
5. System.out.print("bar");
6. }}).start();
7. }
8. }
What is the result?
C
설명없음
QUESTION 85
Given:
class One {
void foo() { }
}
class Two extends One {
14. // insert method here
}
Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
Given:
class One {
void foo() { }
}
class Two extends One {
14. // insert method here
}
Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
B,C,E
설명없음
QUESTION 86
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.)
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.)
B,D
설명없음
QUESTION 87
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?
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?
C
설명없음
QUESTION 88
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.)
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.)
A,C
설명없음
QUESTION 89
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?
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?
C
설명없음
QUESTION 90
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.)
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.)
A,D
설명없음