카테고리 없음
OCJP Study 19
Soul-Learner
2013. 12. 31. 12:29
OCJP(Java 6) 기출문제 연습 19(181~190)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 181
Given:
11. String test = "a1b2c3";
12. String[] tokens = test.split("\\d");
13. for(String s: tokens) System.out.print(s + " ");
What is the result?
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
설명없음
QUESTION 182
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?
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?
B
설명없음
QUESTION 183
Given:
1. public class KungFu {
2. public static void main(String[] args) {
3. Integer x = 400;
4. Integer y = x;
5. x++;
6. StringBuilder sb1 = new StringBuilder("123");
7. StringBuilder sb2 = sb1;
8. sb1.append("5");
9. System.out.println((x == y) + " " + (sb1 == sb2));
10. }
11.}
What is the result?
Given:
1. public class KungFu {
2. public static void main(String[] args) {
3. Integer x = 400;
4. Integer y = x;
5. x++;
6. StringBuilder sb1 = new StringBuilder("123");
7. StringBuilder sb2 = sb1;
8. sb1.append("5");
9. System.out.println((x == y) + " " + (sb1 == sb2));
10. }
11.}
What is the result?
B
설명없음
QUESTION 184
Given:
class Converter {
public static void main(String[] args) {
Integer i = args[0]; // line 13
int j = 12;
System.out.println("It is " + (j == i) + " that j==i.");
}
}
What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?
Given:
class Converter {
public static void main(String[] args) {
Integer i = args[0]; // line 13
int j = 12;
System.out.println("It is " + (j == i) + " that j==i.");
}
}
What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?
D
Integer i = args[0]; Type mismatch: cannot convert from String to Integer
QUESTION 185
Click the Exhibit button.
1. public class A {
2. public String doit(int x, int y){
3. return "a";
4. }
5.
6. public String doit(int... vals){
7. return "b";
8. }
9. }
Given:
25. A a = new A();
26. System.out.println(a.doit(4, 5));
What is the result?
Click the Exhibit button.
1. public class A {
2. public String doit(int x, int y){
3. return "a";
4. }
5.
6. public String doit(int... vals){
7. return "b";
8. }
9. }
Given:
25. A a = new A();
26. System.out.println(a.doit(4, 5));
What is the result?
A
설명없음
QUESTION 186
Which two code fragments correctly create and initialize a static array of int elements? (Choose two.)
Which two code fragments correctly create and initialize a static array of int elements? (Choose two.)
A,B
설명없음
QUESTION 187
Given:
1. public class Plant {
2. private String name;
3.
4. public Plant(String name) {
5. this.name = name;
6. }
7.
8. public String getName() {
9. return name;
10. }
11.}
1. public class Tree extends Plant {
2. public void growFruit() {
3. }
4.
5. public void dropLeaves() {
6. }
7. }
Which statement is true?
Given:
1. public class Plant {
2. private String name;
3.
4. public Plant(String name) {
5. this.name = name;
6. }
7.
8. public String getName() {
9. return name;
10. }
11.}
1. public class Tree extends Plant {
2. public void growFruit() {
3. }
4.
5. public void dropLeaves() {
6. }
7. }
Which statement is true?
D
설명없음
QUESTION 188
Click the Exhibit button.
1. public class GoTest {
2. public static void main(String[] args) {
3. Sente a = new Sente(); a.go();
4. Goban b = new Goban(); b.go();
5. Stone c = new Stone(); c.go();
6. }
7. }
8.
9. class Sente implements Go {
10. public void go(){
11. System.out.println("go in Sente");
12. }
13.}
14.
15.class Goban extends Sente {
16. public void go(){
17. System.out.println("go in Goban");
18. }
19.
20.}
21.class Stone extends Goban implements Go{
22.}
23.
24.interface Go { public void go(); }
What is the result?
Click the Exhibit button.
1. public class GoTest {
2. public static void main(String[] args) {
3. Sente a = new Sente(); a.go();
4. Goban b = new Goban(); b.go();
5. Stone c = new Stone(); c.go();
6. }
7. }
8.
9. class Sente implements Go {
10. public void go(){
11. System.out.println("go in Sente");
12. }
13.}
14.
15.class Goban extends Sente {
16. public void go(){
17. System.out.println("go in Goban");
18. }
19.
20.}
21.class Stone extends Goban implements Go{
22.}
23.
24.interface Go { public void go(); }
What is the result?
C
설명없음
QUESTION 189
Given:
public interface A111 {
String s = "yo";
public void method1();
}
interface B {
}
interface C extends A111, B {
public void method1();
public void method1(int x);
}
What is the result?
Given:
public interface A111 {
String s = "yo";
public void method1();
}
interface B {
}
interface C extends A111, B {
public void method1();
public void method1(int x);
}
What is the result?
A
설명없음
QUESTION 190
Click the Exhibit button.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.interface Foo{
11. int bar();
12.}
13.
14.public class Beta {
15.
16. class A implements Foo {
17. public int bar(){ return 1; }
18. }
19.
20. public int fubar(Foo foo){ return foo.bar(); }
21.
22. public void testFoo(){
23.
24. class A implements Foo{
25. public int bar(){return 2;}
26. }
27.
28. System.out.println(fubar(new A()));
29. }
30.
31. public static void main(String[] args) {
32. new Beta().testFoo();
33. }
34.}
Which three statements are true? (Choose three.)
Click the Exhibit button.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.interface Foo{
11. int bar();
12.}
13.
14.public class Beta {
15.
16. class A implements Foo {
17. public int bar(){ return 1; }
18. }
19.
20. public int fubar(Foo foo){ return foo.bar(); }
21.
22. public void testFoo(){
23.
24. class A implements Foo{
25. public int bar(){return 2;}
26. }
27.
28. System.out.println(fubar(new A()));
29. }
30.
31. public static void main(String[] args) {
32. new Beta().testFoo();
33. }
34.}
Which three statements are true? (Choose three.)
B,E,F
설명없음