최신Oracle Java Standard Edition 6 Programmer Certified Professional - 1Z0-851무료샘플문제
문제1
Given:
1.public class Breaker2 {
2.static String o = "";
3.public static void main(String[] args) {
4.z:
5.for(int x = 2; x < 7; x++) {
6.if(x==3) continue;
7.if(x==5) break z;
8.o = o + x;
9.}
10.System.out.println(o);
11.}
12.}
What is the result?
Given:
1.public class Breaker2 {
2.static String o = "";
3.public static void main(String[] args) {
4.z:
5.for(int x = 2; x < 7; x++) {
6.if(x==3) continue;
7.if(x==5) break z;
8.o = o + x;
9.}
10.System.out.println(o);
11.}
12.}
What is the result?
정답: B
문제2
Given a pre-generics implementation of a method:
11.public static int sum(List list) {
12.int sum = 0;
13.for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
14.int i = ((Integer)iter.next()).intValue();
15.sum += i;
16.}
17.return sum;
18.}
What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.)
Given a pre-generics implementation of a method:
11.public static int sum(List list) {
12.int sum = 0;
13.for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
14.int i = ((Integer)iter.next()).intValue();
15.sum += i;
16.}
17.return sum;
18.}
What three changes allow the class to be used with generics and avoid an unchecked warning? (Choose three.)
정답: A,C,D
문제3
Given:
22.StringBuilder sb1 = new StringBuilder("123");
23.String s1 = "123";
24.// insert code here
25.System.out.println(sb1 + " " + s1);
Which code fragment, inserted at line 24, outputs "123abc 123abc"?
Given:
22.StringBuilder sb1 = new StringBuilder("123");
23.String s1 = "123";
24.// insert code here
25.System.out.println(sb1 + " " + s1);
Which code fragment, inserted at line 24, outputs "123abc 123abc"?
정답: E
문제4
Given a class Repetition:
1.package utils;
2.3.
public class Repetition {
4.public static String twice(String s) { return s + s; }
5.} and given another class Demo: 1. // insert code here
2.3.
public class Demo {
4.public static void main(String[] args) {
5.System.out.println(twice("pizza"));
6.}
7.}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
Given a class Repetition:
1.package utils;
2.3.
public class Repetition {
4.public static String twice(String s) { return s + s; }
5.} and given another class Demo: 1. // insert code here
2.3.
public class Demo {
4.public static void main(String[] args) {
5.System.out.println(twice("pizza"));
6.}
7.}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
정답: F
문제5
Given:
12.import java.util.*;
13.public class Explorer1 {
14.public static void main(String[] args) {
15.TreeSet<Integer> s = new TreeSet<Integer>();
16.TreeSet<Integer> subs = new TreeSet<Integer>();
17.for(int i = 606; i < 613; i++)
18.if(i%2 == 0) s.add(i);
19.subs = (TreeSet)s.subSet(608, true, 611, true);
20.s.add(609);
21.System.out.println(s + " " + subs);
22.}
23.}
What is the result?
Given:
12.import java.util.*;
13.public class Explorer1 {
14.public static void main(String[] args) {
15.TreeSet<Integer> s = new TreeSet<Integer>();
16.TreeSet<Integer> subs = new TreeSet<Integer>();
17.for(int i = 606; i < 613; i++)
18.if(i%2 == 0) s.add(i);
19.subs = (TreeSet)s.subSet(608, true, 611, true);
20.s.add(609);
21.System.out.println(s + " " + subs);
22.}
23.}
What is the result?
정답: F
문제6
Given:
1.public class BuildStuff {
2.public static void main(String[] args) {
3.Boolean test = new Boolean(true);
4.Integer x = 343;
5.Integer y = new BuildStuff().go(test, x);
6.System.out.println(y);
7.}
8.int go(Boolean b, int i) {
9.if(b) return (i/7);
10.return (i/49);
11.}
12.}
What is the result?
Given:
1.public class BuildStuff {
2.public static void main(String[] args) {
3.Boolean test = new Boolean(true);
4.Integer x = 343;
5.Integer y = new BuildStuff().go(test, x);
6.System.out.println(y);
7.}
8.int go(Boolean b, int i) {
9.if(b) return (i/7);
10.return (i/49);
11.}
12.}
What is the result?
정답: D
문제7
Given:
1.class Alligator {
2.public static void main(String[] args) {
3.int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
4.int [][]y = x;
5.System.out.println(y[2][1]);
6.}
7.}
What is the result?
Given:
1.class Alligator {
2.public static void main(String[] args) {
3.int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};
4.int [][]y = x;
5.System.out.println(y[2][1]);
6.}
7.}
What is the result?
정답: E
문제8
Given:
5.class Building { }
6.public class Barn extends Building {
7.public static void main(String[] args) {
8.Building build1 = new Building();
9.Barn barn1 = new Barn();
10.Barn barn2 = (Barn) build1;
11.Object obj1 = (Object) build1;
12.String str1 = (String) build1;
13.Building build2 = (Building) barn1;
14.}
15.}
Which is true?
Given:
5.class Building { }
6.public class Barn extends Building {
7.public static void main(String[] args) {
8.Building build1 = new Building();
9.Barn barn1 = new Barn();
10.Barn barn2 = (Barn) build1;
11.Object obj1 = (Object) build1;
12.String str1 = (String) build1;
13.Building build2 = (Building) barn1;
14.}
15.}
Which is true?
정답: B
문제9
Given:
11.public static Iterator reverse(List list) {
12.Collections.reverse(list);
13.return list.iterator();
14.}
15.public static void main(String[] args) {
16.List list = new ArrayList();
17.list.add("1"); list.add("2"); list.add("3");
18.for (Object obj: reverse(list))
19.System.out.print(obj + ", ");
20.}
What is the result?
Given:
11.public static Iterator reverse(List list) {
12.Collections.reverse(list);
13.return list.iterator();
14.}
15.public static void main(String[] args) {
16.List list = new ArrayList();
17.list.add("1"); list.add("2"); list.add("3");
18.for (Object obj: reverse(list))
19.System.out.print(obj + ", ");
20.}
What is the result?
정답: B
문제10
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"?
정답: D
문제11
Given:
11.public void testIfA() {
12.if (testIfB("True")) {
13.System.out.println("True");
14.} else {
15.System.out.println("Not true");
16.}
17.}
18.public Boolean testIfB(String str) {
19.return Boolean.valueOf(str);
20.}
What is the result when method testIfA is invoked?
Given:
11.public void testIfA() {
12.if (testIfB("True")) {
13.System.out.println("True");
14.} else {
15.System.out.println("Not true");
16.}
17.}
18.public Boolean testIfB(String str) {
19.return Boolean.valueOf(str);
20.}
What is the result when method testIfA is invoked?
정답: E
문제12
Click the Exhibit button. What is the output of the program shown in the exhibit?

Click the Exhibit button. What is the output of the program shown in the exhibit?

정답: B
문제13
Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
정답: A,D
문제14
Given:
3.import java.util.*;
4.public class G1 {
5.public void takeList(List<? extends String> list) {
6.// insert code here
7.}
8.}
Which three code fragments, inserted independently at line 6, will compile? (Choose three.)
Given:
3.import java.util.*;
4.public class G1 {
5.public void takeList(List<? extends String> list) {
6.// insert code here
7.}
8.}
Which three code fragments, inserted independently at line 6, will compile? (Choose three.)
정답: B,C,E
문제15
Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)
Which two code fragments will execute the method doStuff() in a separate thread? (Choose two.)
정답: C,D
문제16
Given:
11.public static void main(String[] args) {
12.Integer i = new Integer(1) + new Integer(2);
13.switch(i) {
14.case 3: System.out.println("three"); break;
15.default: System.out.println("other"); break;
16.}
17.}
What is the result?
Given:
11.public static void main(String[] args) {
12.Integer i = new Integer(1) + new Integer(2);
13.switch(i) {
14.case 3: System.out.println("three"); break;
15.default: System.out.println("other"); break;
16.}
17.}
What is the result?
정답: E