最新的Oracle Java Standard Edition 6 Programmer Certified Professional - 1Z0-851免費考試真題
問題1
Given:
11.class Converter {
12.public static void main(String[] args) {
13.Integer i = args[0];
14.int j = 12;
15.System.out.println("It is " + (j==i) + " that j==i.");
16.}
17.}
What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?
Given:
11.class Converter {
12.public static void main(String[] args) {
13.Integer i = args[0];
14.int j = 12;
15.System.out.println("It is " + (j==i) + " that j==i.");
16.}
17.}
What is the result when the programmer attempts to compile the code and run it with the command java Converter 12?
正確答案: B
問題2
DRAG DROP
Click the Task button.

DRAG DROP
Click the Task button.

正確答案:

問題3
Given:
10.class Nav{
11.public enum Direction { NORTH, SOUTH, EAST, WEST }
12.}
13.public class Sprite{
14.// insert code here
15.}
Which code, inserted at line 14, allows the Sprite class to compile?
Given:
10.class Nav{
11.public enum Direction { NORTH, SOUTH, EAST, WEST }
12.}
13.public class Sprite{
14.// insert code here
15.}
Which code, inserted at line 14, allows the Sprite class to compile?
正確答案: C
問題4
Given:
33.try {
34.// some code here
35.} catch (NullPointerException e1) {
36.System.out.print("a");
37.} catch (Exception e2) {
38.System.out.print("b");
39.} finally {
40.System.out.print("c");
41.}
If some sort of exception is thrown at line 34, which output is possible?
Given:
33.try {
34.// some code here
35.} catch (NullPointerException e1) {
36.System.out.print("a");
37.} catch (Exception e2) {
38.System.out.print("b");
39.} finally {
40.System.out.print("c");
41.}
If some sort of exception is thrown at line 34, which output is possible?
正確答案: A
問題5
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.)
正確答案: A,B,C
問題6
Given:
10.public class SuperCalc {
11.protected static int multiply(int a, int b) { return a * b;}
12.} and:
20.public class SubCalc extends SuperCalc{
21.public static int multiply(int a, int b) {
22.int c = super.multiply(a, b);
23.return c;
24.}
25.} and:
30.SubCalc sc = new SubCalc ();
31.System.out.println(sc.multiply(3,4));
32.System.out.println(SubCalc.multiply(2,2));
What is the result?
Given:
10.public class SuperCalc {
11.protected static int multiply(int a, int b) { return a * b;}
12.} and:
20.public class SubCalc extends SuperCalc{
21.public static int multiply(int a, int b) {
22.int c = super.multiply(a, b);
23.return c;
24.}
25.} and:
30.SubCalc sc = new SubCalc ();
31.System.out.println(sc.multiply(3,4));
32.System.out.println(SubCalc.multiply(2,2));
What is the result?
正確答案: C
問題7
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.)
正確答案: C,F
問題8
Given:
21.abstract class C1 {
22.public C1() { System.out.print(1); }
23.}
24.class C2 extends C1 {
25.public C2() { System.out.print(2); }
26.}
27.class C3 extends C2 {
28.public C3() { System.out.println(3); }
29.}
30.public class Ctest {
31.public static void main(String[] a) { new C3(); }
32.}
What is the result?
Given:
21.abstract class C1 {
22.public C1() { System.out.print(1); }
23.}
24.class C2 extends C1 {
25.public C2() { System.out.print(2); }
26.}
27.class C3 extends C2 {
28.public C3() { System.out.println(3); }
29.}
30.public class Ctest {
31.public static void main(String[] a) { new C3(); }
32.}
What is the result?
正確答案: F
問題9
Click the Exhibit button. What is the result?

Click the Exhibit button. What is the result?

正確答案: D
問題10
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:
1.import java.io.*;
2.public class Maker {
3.public static void main(String[] args) {
4.File dir = new File("dir");
5.File f = new File(dir, "f");
6.}
7.}
Which statement is true?
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:
1.import java.io.*;
2.public class Maker {
3.public static void main(String[] args) {
4.File dir = new File("dir");
5.File f = new File(dir, "f");
6.}
7.}
Which statement is true?
正確答案: B
問題11
Given:
1.public class Threads4 {
2.public static void main (String[] args) {
3.new Threads4().go();
4.}
5.public void go() {
6.Runnable r = new Runnable() {
7.public void run() {
8.System.out.print("foo");
9.}
10.};
11.Thread t = new Thread(r);
12.t.start();
13.t.start();
14.}
15.}
What is the result?
Given:
1.public class Threads4 {
2.public static void main (String[] args) {
3.new Threads4().go();
4.}
5.public void go() {
6.Runnable r = new Runnable() {
7.public void run() {
8.System.out.print("foo");
9.}
10.};
11.Thread t = new Thread(r);
12.t.start();
13.t.start();
14.}
15.}
What is the result?
正確答案: A
問題12
Given:
11.public class Test {
12.public enum Dogs {collie, harrier, shepherd};
13.public static void main(String [] args) {
14.Dogs myDog = Dogs.shepherd;
15.switch (myDog) {
16.case collie:
17.System.out.print("collie ");
18.case default:
19.System.out.print("retriever ");
20.case harrier:
21.System.out.print("harrier ");
22.}
23.}
24.}
What is the result?
Given:
11.public class Test {
12.public enum Dogs {collie, harrier, shepherd};
13.public static void main(String [] args) {
14.Dogs myDog = Dogs.shepherd;
15.switch (myDog) {
16.case collie:
17.System.out.print("collie ");
18.case default:
19.System.out.print("retriever ");
20.case harrier:
21.System.out.print("harrier ");
22.}
23.}
24.}
What is the result?
正確答案: E
問題13
Given:
11.public static void main(String[] args) {
12.String str = "null";
13.if (str == null) {
14.System.out.println("null");
15.} else (str.length() == 0) {
16.System.out.println("zero");
17.} else {
18.System.out.println("some");
19.}
20.}
What is the result?
Given:
11.public static void main(String[] args) {
12.String str = "null";
13.if (str == null) {
14.System.out.println("null");
15.} else (str.length() == 0) {
16.System.out.println("zero");
17.} else {
18.System.out.println("some");
19.}
20.}
What is the result?
正確答案: E
問題14
Given:
1.import java.util.*;
2.public class WrappedString {
3.private String s;
4.public WrappedString(String s) { this.s = s; }
5.public static void main(String[] args) {
6.HashSet<Object> hs = new HashSet<Object>();
7.WrappedString ws1 = new WrappedString("aardvark");
8.WrappedString ws2 = new WrappedString("aardvark");
9.String s1 = new String("aardvark");
10.String s2 = new String("aardvark");
11.hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
12.System.out.println(hs.size()); } } What is the result?
Given:
1.import java.util.*;
2.public class WrappedString {
3.private String s;
4.public WrappedString(String s) { this.s = s; }
5.public static void main(String[] args) {
6.HashSet<Object> hs = new HashSet<Object>();
7.WrappedString ws1 = new WrappedString("aardvark");
8.WrappedString ws2 = new WrappedString("aardvark");
9.String s1 = new String("aardvark");
10.String s2 = new String("aardvark");
11.hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2);
12.System.out.println(hs.size()); } } What is the result?
正確答案: F