Oracle Java Standard Edition 5 Programmer Certified Professional - 1Z0-853 Exam Practice Test
Given:
1.interface A { public void aMethod(); }
2.interface B { public void bMethod(); }
3.interface C extends A,B { public void cMethod(); }
4.class D implements B {
5.public void bMethod(){}
6.}
7.class E extends D implements C {
8.public void aMethod(){}
9.public void bMethod(){}
10.
public void cMethod(){}
11.
}
What is the result?
1.interface A { public void aMethod(); }
2.interface B { public void bMethod(); }
3.interface C extends A,B { public void cMethod(); }
4.class D implements B {
5.public void bMethod(){}
6.}
7.class E extends D implements C {
8.public void aMethod(){}
9.public void bMethod(){}
10.
public void cMethod(){}
11.
}
What is the result?
Correct Answer: A
Vote an answer
Given:
11.
public class Key {
12.
private long id1;
13.
private long id2;
14.
15.
// class Key methods
16.
}
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap.
Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.)
11.
public class Key {
12.
private long id1;
13.
private long id2;
14.
15.
// class Key methods
16.
}
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap.
Which two methods should be overridden to assure that Key works correctly as a key? (Choose two.)
Correct Answer: A,D
Vote an answer
Given this method in a class:
21.
public String toString() {
22.
StringBuffer buffer = new StringBuffer();
23.
buffer.append('<');
24.
buffer.append(this.name);
25.
buffer.append('>');
26.
return buffer.toString();
27.
}
Which statement is true?
21.
public String toString() {
22.
StringBuffer buffer = new StringBuffer();
23.
buffer.append('<');
24.
buffer.append(this.name);
25.
buffer.append('>');
26.
return buffer.toString();
27.
}
Which statement is true?
Correct Answer: D
Vote an answer
Given:
1.public class Plant {
2.private String name;
3.public Plant(String name) { this.name = name; }
4.public String getName() { return name; }
5.}
1.public class Tree extends Plant {
2.public void growFruit() { }
3.public void dropLeaves() { }
4.}
Which statement is true?
1.public class Plant {
2.private String name;
3.public Plant(String name) { this.name = name; }
4.public String getName() { return name; }
5.}
1.public class Tree extends Plant {
2.public void growFruit() { }
3.public void dropLeaves() { }
4.}
Which statement is true?
Correct Answer: E
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: B
Vote an answer
Click the Exhibit button. Given:
34.
Test t = new Test();
35.
t.method(5);
What is the output from line 5 of the Test class?

34.
Test t = new Test();
35.
t.method(5);
What is the output from line 5 of the Test class?

Correct Answer: D
Vote an answer
Given:
10. interface Jumper { public void jump(); } ...
20. class Animal {} ...
30.
class Dog extends Animal {
31.
Tail tail;
32.
} ...
40.
class Beagle extends Dog implements Jumper{
41.
public void jump() {}
42.
} ...
50.
class Cat implements Jumper{
51.
public void jump() {}
52.
}
Which three are true? (Choose three.)
10. interface Jumper { public void jump(); } ...
20. class Animal {} ...
30.
class Dog extends Animal {
31.
Tail tail;
32.
} ...
40.
class Beagle extends Dog implements Jumper{
41.
public void jump() {}
42.
} ...
50.
class Cat implements Jumper{
51.
public void jump() {}
52.
}
Which three are true? (Choose three.)
Correct Answer: A,E,G
Vote an answer
Given:
11.
public class Test {
12.
public static void main(String [] args) {
13.
int x = 5;
14.
boolean b1 = true;
15.
boolean b2 = false;
16.
17.
if ((x == 4) && !b2 )
18.
System.out.print("1 ");
19.
System.out.print("2 ");
20.
if ((b2 = true) && b1 )
21.
System.out.print("3 ");
22.
}
23.
}
What is the result?
11.
public class Test {
12.
public static void main(String [] args) {
13.
int x = 5;
14.
boolean b1 = true;
15.
boolean b2 = false;
16.
17.
if ((x == 4) && !b2 )
18.
System.out.print("1 ");
19.
System.out.print("2 ");
20.
if ((b2 = true) && b1 )
21.
System.out.print("3 ");
22.
}
23.
}
What is the result?
Correct Answer: D
Vote an answer
Given:
11.
static void test() {
12.
try {
13.
String x = null;
14.
System.out.print(x.toString() + " ");
15.
}
16.
finally { System.out.print("finally "); }
17.
}
18.
public static void main(String[] args) {
19.
try { test(); }
20.
catch (Exception ex) { System.out.print("exception "); }
21.
}
What is the result?
11.
static void test() {
12.
try {
13.
String x = null;
14.
System.out.print(x.toString() + " ");
15.
}
16.
finally { System.out.print("finally "); }
17.
}
18.
public static void main(String[] args) {
19.
try { test(); }
20.
catch (Exception ex) { System.out.print("exception "); }
21.
}
What is the result?
Correct Answer: C
Vote an answer
Given:
10.
interface Foo { int bar(); }
11.
public class Sprite {
12.
public int fubar( Foo foo ) { return foo.bar(); }
13.
public void testFoo() {
14.
fubar(
15.
// insert code here
16.
);
17.
}
18.
}
Which code, inserted at line 15, allows the class Sprite to compile?
10.
interface Foo { int bar(); }
11.
public class Sprite {
12.
public int fubar( Foo foo ) { return foo.bar(); }
13.
public void testFoo() {
14.
fubar(
15.
// insert code here
16.
);
17.
}
18.
}
Which code, inserted at line 15, allows the class Sprite to compile?
Correct Answer: C
Vote an answer
