Oracle Java Standard Edition 5 Programmer Certified Professional (1Z0-853) Free Practice Test
Question 1
DRAG DROP
Click the Task button.

Click the Task button.

Correct Answer:

Question 2
Click the Exhibit button.
Given:
ClassA a = new ClassA();
a.methodA();
What is the result?

Given:
ClassA a = new ClassA();
a.methodA();
What is the result?

Correct Answer: B
Question 3
DRAG DROP
Click the Task button.

Click the Task button.

Correct Answer:

Question 4
When comparing java.io.BufferedWriter to java.io.FileWriter, which capability exists as a method in only one of the two?
Correct Answer: E
Question 5
Given:
10.
public class Foo {
11.
static int[] a;
12.
static { a[0]=2; }
13.
public static void main( String[] args ) {}
14.
}
Which exception or error will be thrown when a programmer attempts to run this code?
10.
public class Foo {
11.
static int[] a;
12.
static { a[0]=2; }
13.
public static void main( String[] args ) {}
14.
}
Which exception or error will be thrown when a programmer attempts to run this code?
Correct Answer: D
Question 6
Given:
1.class ClassA {
2.public int numberOfInstances;
3.protected ClassA(int numberOfInstances) {
4.this.numberOfInstances = numberOfInstances;
5.}
6.}
7.public class ExtendedA extends ClassA {
8.private ExtendedA(int numberOfInstances) {
9.super(numberOfInstances);
10.
}
11.
public static void main(String[] args) {
12.
ExtendedA ext = new ExtendedA(420);
13.
System.out.print(ext.numberOfInstances);
14.
}
15.
}
Which statement is true?
1.class ClassA {
2.public int numberOfInstances;
3.protected ClassA(int numberOfInstances) {
4.this.numberOfInstances = numberOfInstances;
5.}
6.}
7.public class ExtendedA extends ClassA {
8.private ExtendedA(int numberOfInstances) {
9.super(numberOfInstances);
10.
}
11.
public static void main(String[] args) {
12.
ExtendedA ext = new ExtendedA(420);
13.
System.out.print(ext.numberOfInstances);
14.
}
15.
}
Which statement is true?
Correct Answer: B
Question 7
Given:
11.
static void test() throws Error {
12.
if (true) throw new AssertionError();
13.
System.out.print("test ");
14.
}
15.
public static void main(String[] args) {
16.
try { test(); }
17.
catch (Exception ex) { System.out.print("exception "); }
18.
System.out.print("end ");
19.
}
What is the result?
11.
static void test() throws Error {
12.
if (true) throw new AssertionError();
13.
System.out.print("test ");
14.
}
15.
public static void main(String[] args) {
16.
try { test(); }
17.
catch (Exception ex) { System.out.print("exception "); }
18.
System.out.print("end ");
19.
}
What is the result?
Correct Answer: D
Question 8
Given:
23.
int z = 5;
24.
25.
public void stuff1(int x) {
26.
assert (x > 0);
27.
switch(x) {
28.
case 2: x = 3;
29.
default: assert false; } }
30.
31.
private void stuff2(int y) { assert (y < 0); }
32.
33.
private void stuff3() { assert (stuff4()); }
34.
35.
private boolean stuff4() { z = 6; return false; }
Which statement is true?
23.
int z = 5;
24.
25.
public void stuff1(int x) {
26.
assert (x > 0);
27.
switch(x) {
28.
case 2: x = 3;
29.
default: assert false; } }
30.
31.
private void stuff2(int y) { assert (y < 0); }
32.
33.
private void stuff3() { assert (stuff4()); }
34.
35.
private boolean stuff4() { z = 6; return false; }
Which statement is true?
Correct Answer: A
Question 9
DRAG DROP
Click the Task button.

Click the Task button.

Correct Answer:

Question 10
Given:
1.class TestA {
2.public void start() { System.out.println("TestA"); }
3.}
4.public class TestB extends TestA {
5.public void start() { System.out.println("TestB"); }
6.public static void main(String[] args) {
7.((TestA)new TestB()).start();
8.}
9.}
What is the result?
1.class TestA {
2.public void start() { System.out.println("TestA"); }
3.}
4.public class TestB extends TestA {
5.public void start() { System.out.println("TestB"); }
6.public static void main(String[] args) {
7.((TestA)new TestB()).start();
8.}
9.}
What is the result?
Correct Answer: B
Question 11
DRAG DROP
Click the Task button.

Click the Task button.

Correct Answer:

Question 12
Given:
12.
public class Wow {
13.
public static void go(short n) {System.out.println("short");}
14.
public static void go(Short n) {System.out.println("SHORT");}
15.
public static void go(Long n) {System.out.println(" LONG");}
16.
public static void main(String [] args) {
17.
Short y = 6;
18.
int z = 7;
19.
go(y);
20.
go(z);
21.
}
22.
}
What is the result?
12.
public class Wow {
13.
public static void go(short n) {System.out.println("short");}
14.
public static void go(Short n) {System.out.println("SHORT");}
15.
public static void go(Long n) {System.out.println(" LONG");}
16.
public static void main(String [] args) {
17.
Short y = 6;
18.
int z = 7;
19.
go(y);
20.
go(z);
21.
}
22.
}
What is the result?
Correct Answer: D
Question 13
Given:
11.
public class Person {
12.
private String name;
13.
public Person(String name) {
14.
this.name = name;
15.
}
16.
public boolean equals(Object o) {
17.
if ( ! o instanceof Person ) return false;
18.
Person p = (Person) o;
19.
return p.name.equals(this.name);
20.
}
21.
}
Which statement is true?
11.
public class Person {
12.
private String name;
13.
public Person(String name) {
14.
this.name = name;
15.
}
16.
public boolean equals(Object o) {
17.
if ( ! o instanceof Person ) return false;
18.
Person p = (Person) o;
19.
return p.name.equals(this.name);
20.
}
21.
}
Which statement is true?
Correct Answer: B
Question 14
DRAG DROP
Click the Task button.

Click the Task button.

Correct Answer:
