카테고리 없음
OCJP Study 13
Soul-Learner
2013. 12. 29. 13:56
OCJP(Java 6) 기출문제 연습 13(121~130)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 121
Given:
1. import java.io.*;
2.
6. public class Talk {
7. public static void main(String[] args) {
8. Console c = new Console();
9. String pw;
10. System.out.print("password: ");
11. pw = c.readLine();
12. System.out.println("got " + pw);
13. }
14.}
If the user types the password aiko when prompted, what is the result?
Given:
1. import java.io.*;
2.
6. public class Talk {
7. public static void main(String[] args) {
8. Console c = new Console();
9. String pw;
10. System.out.print("password: ");
11. pw = c.readLine();
12. System.out.println("got " + pw);
13. }
14.}
If the user types the password aiko when prompted, what is the result?
E
Tested and the compilation really fails on line 8 with the message "The constructor Console() is not visible"
ZZZ
ZZZ
QUESTION 122
Given:
11. String test = "Test A. Test B. Test C.";
12. // insert code here
13. String[] result = test.split(regex);
Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?
Given:
11. String test = "Test A. Test B. Test C.";
12. // insert code here
13. String[] result = test.split(regex);
Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?
E
설명없음
QUESTION 123
Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10.public void cMethod(){}
11.}
What is the result?
Given:
1. interface A { public void aMethod(); }
2. interface B { public void bMethod(); }
3. interface C extends A,B { public void cMethod(); }
4. class D implements B {
5. public void bMethod(){}
6. }
7. class E extends D implements C {
8. public void aMethod(){}
9. public void bMethod(){}
10.public void cMethod(){}
11.}
What is the result?
F
설명없음
QUESTION 124
Click the Exhibit button.
What is the result?
1. public class SimpleCalc {
2. public int value;
3. public void calculate() { value == 7; }
4. }
And:
1. public class MultiCalc extends SimpleCalc {
2. public void calculate() { value -= 3; }
3. public void calculate(int multiplier) {
4. calculate();
5. super.calculate();
6. value *= multiplier;
7. }
8. public static void main(String[] args) {
9. MultiCalc calculator = new MultiCalc();
10. calculator.calculate(2);
11. System.out.println("Value is: "+ calculator.value);
12. }
13. }
Click the Exhibit button.
What is the result?
1. public class SimpleCalc {
2. public int value;
3. public void calculate() { value == 7; }
4. }
And:
1. public class MultiCalc extends SimpleCalc {
2. public void calculate() { value -= 3; }
3. public void calculate(int multiplier) {
4. calculate();
5. super.calculate();
6. value *= multiplier;
7. }
8. public static void main(String[] args) {
9. MultiCalc calculator = new MultiCalc();
10. calculator.calculate(2);
11. System.out.println("Value is: "+ calculator.value);
12. }
13. }
A
설명없음
QUESTION 125
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?
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?
D
설명없음
QUESTION 126
Given:
1. class Mammal {
2. }
3.
4. class Raccoon extends Mammal {
5. Mammal m = new Mammal();
6. }
7.
8. class BabyRaccoon extends Mammal {
9. }
10.
Which four statements are true? (Choose four.)
Given:
1. class Mammal {
2. }
3.
4. class Raccoon extends Mammal {
5. Mammal m = new Mammal();
6. }
7.
8. class BabyRaccoon extends Mammal {
9. }
10.
Which four statements are true? (Choose four.)
A,B,C,F
설명없음
QUESTION 127
Given:
interface A { void x(); }
class B implements A { public void x() {} public void y() {} }
class C extends B { public void x() {} }
And:
java.util.List<A> list = new java.util.ArrayList<A>();
list.add(new B());
list.add(new C());
for (A a : list) {
a.x();
a.y(); //Linea 25
}
What is the result?
Given:
interface A { void x(); }
class B implements A { public void x() {} public void y() {} }
class C extends B { public void x() {} }
And:
java.util.List<A> list = new java.util.ArrayList<A>();
list.add(new B());
list.add(new C());
for (A a : list) {
a.x();
a.y(); //Linea 25
}
What is the result?
F
설명없음
QUESTION 128
Given:
1.
2. public class Hi {
3. void m1() { }
4. protected void() m2 { }
5. }
6. class Lois extends Hi {
7. // insert code here
8. }
Which four code fragments, inserted independently at line 7, will compile? (Choose four.)
Given:
1.
2. public class Hi {
3. void m1() { }
4. protected void() m2 { }
5. }
6. class Lois extends Hi {
7. // insert code here
8. }
Which four code fragments, inserted independently at line 7, will compile? (Choose four.)
A,B,E,F
설명없음
QUESTION 129
Which four statements are true? (Choose four.)
Which four statements are true? (Choose four.)
C,D,E,G
설명없음
QUESTION 130
Given:
public class Hello {
String title;
int value;
public Hello() {
title += " World";
}
public Hello(int value) {
this.value = value;
title = "Hello";
Hello();
}
}
and:
Hello c = new Hello(5);
System.out.println(c.title);
What is the result?
Given:
public class Hello {
String title;
int value;
public Hello() {
title += " World";
}
public Hello(int value) {
this.value = value;
title = "Hello";
Hello();
}
}
and:
Hello c = new Hello(5);
System.out.println(c.title);
What is the result?
C
on the last line, c.title isn't acessible
ZZZ
ZZZ