Oracle Java Standard Edition 5 Programmer Certified Professional - 1Z0-853 Exam Practice Test
Given:
1.public class TestSeven extends Thread {
2.private static int x;
3.public synchronized void doThings() {
4.int current = x;
5.current++;
6.x = current;
7.}
8.public void run() {
9.doThings();
10.
}
11.}
Which statement is true?
1.public class TestSeven extends Thread {
2.private static int x;
3.public synchronized void doThings() {
4.int current = x;
5.current++;
6.x = current;
7.}
8.public void run() {
9.doThings();
10.
}
11.}
Which statement is true?
Correct Answer: A
Vote an answer
Given:
d is a valid, non-null Date object
df is a valid, non-null DateFormat object set to the current locale
What outputs the current locale's country name and the appropriate version of d's date?
d is a valid, non-null Date object
df is a valid, non-null DateFormat object set to the current locale
What outputs the current locale's country name and the appropriate version of d's date?
Correct Answer: D
Vote an answer
Given:
11.
public static void test(String str) {
12.
int check = 4;
13.
if (check = str.length()) {
14.
System.out.print(str.charAt(check -= 1) +", ");
15.
} else {
16.
System.out.print(str.charAt(0) + ", ");
17.
}
18.
}
and the invocation:
21.
test("four");
22.
test("tee");
23.
test("to");
What is the result?
11.
public static void test(String str) {
12.
int check = 4;
13.
if (check = str.length()) {
14.
System.out.print(str.charAt(check -= 1) +", ");
15.
} else {
16.
System.out.print(str.charAt(0) + ", ");
17.
}
18.
}
and the invocation:
21.
test("four");
22.
test("tee");
23.
test("to");
What is the result?
Correct Answer: A
Vote an answer
Given:
12.
import java.io.*;
13.
public class Forest implements Serializable {
14.
private Tree tree = new Tree();
15.
public static void main(String [] args) {
16.
Forest f = new Forest();
17.
try {
18.
FileOutputStream fs = new FileOutputStream("Forest.ser");
19.
ObjectOutputStream os = new ObjectOutputStream(fs);
20.
os.writeObject(f); os.close();
21.
} catch (Exception ex) { ex.printStackTrace(); }
22.
} }
23.
24.
class Tree { }
What is the result?
12.
import java.io.*;
13.
public class Forest implements Serializable {
14.
private Tree tree = new Tree();
15.
public static void main(String [] args) {
16.
Forest f = new Forest();
17.
try {
18.
FileOutputStream fs = new FileOutputStream("Forest.ser");
19.
ObjectOutputStream os = new ObjectOutputStream(fs);
20.
os.writeObject(f); os.close();
21.
} catch (Exception ex) { ex.printStackTrace(); }
22.
} }
23.
24.
class Tree { }
What is the result?
Correct Answer: C
Vote an answer
Given a valid DateFormat object named df, and
16.
Date d = new Date(0L);
17.
String ds = "December 15, 2004";
18.
// insert code here
What updates d's value with the date represented by ds?
16.
Date d = new Date(0L);
17.
String ds = "December 15, 2004";
18.
// insert code here
What updates d's value with the date represented by ds?
Correct Answer: C
Vote an answer
Given:
1.package geometry;
2.public class Hypotenuse {
3.public InnerTriangle it = new InnerTriangle();
4.class InnerTriangle {
5.public int base;
6.public int height;
7.}
8.}
Which statement is true about the class of an object that can reference the variable base?
1.package geometry;
2.public class Hypotenuse {
3.public InnerTriangle it = new InnerTriangle();
4.class InnerTriangle {
5.public int base;
6.public int height;
7.}
8.}
Which statement is true about the class of an object that can reference the variable base?
Correct Answer: D
Vote an answer
Given:
55.
int [] x = {1, 2, 3, 4, 5};
56.
int y[] = x;
57.
System.out.println(y[2]); Which statement is true?
55.
int [] x = {1, 2, 3, 4, 5};
56.
int y[] = x;
57.
System.out.println(y[2]); Which statement is true?
Correct Answer: A
Vote an answer
Given:
10: public class Hello {
11: String title;
12: int value;
13: public Hello() {
14: title += " World";
15: }
16: public Hello(int value) {
17: this.value = value;
18: title = "Hello"; 19: Hello();
20: }
21: }
and:
30: Hello c = new Hello(5);
31: System.out.println(c.title);
What is the result?
10: public class Hello {
11: String title;
12: int value;
13: public Hello() {
14: title += " World";
15: }
16: public Hello(int value) {
17: this.value = value;
18: title = "Hello"; 19: Hello();
20: }
21: }
and:
30: Hello c = new Hello(5);
31: System.out.println(c.title);
What is the result?
Correct Answer: B
Vote an answer
Given:
11.
rbo = new ReallyBigObject();
12.
// more code here
13.
rbo = null;
14.
/* insert code here */
Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?
11.
rbo = new ReallyBigObject();
12.
// more code here
13.
rbo = null;
14.
/* insert code here */
Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?
Correct Answer: C
Vote an answer

