Welcome to TestSimulate

Pass Your Next Certification Exam Fast!

Everything you need to prepare, learn & pass your certification exam easily.

365 days free updates. First attempt guaranteed success.

Oracle Java Standard Edition 6 Programmer Certified Professional (1Z0-851) Free Practice Test

Question 1
Given:
10.interface Data { public void load(); }
11.abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?

Correct Answer: A
Question 2
Given:
1.interface DoStuff2 {
2.float getRange(int low, int high); }
3.4.
interface DoMore {
5.float getAvg(int a, int b, int c); }
6.7.
abstract class DoAbstract implements DoStuff2, DoMore { }
8.9.
class DoStuff implements DoStuff2 {
10.public float getRange(int x, int y) { return 3.14f; } }
11.12.
interface DoAll extends DoMore {
13.float getAvg(int a, int b, int c, int d); } What is the result?

Correct Answer: G
Question 3
Given:
1.public class Drink implements Comparable {
2.public String name;
3.public int compareTo(Object o) {
4.return 0;
5.}
6.} and:
20.Drink one = new Drink();
21.Drink two = new Drink();
22.one.name= "Coffee";
23.two.name= "Tea";
24.TreeSet set = new TreeSet();
25.set.add(one);
26.set.add(two);
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?

Correct Answer: A
Question 4
Given:
11.public static void main(String[] args) {
12.try {
13.args = null;
14.args[0] = "test";
15.System.out.println(args[0]);
16.} catch (Exception ex) {
17.System.out.println("Exception");
18.} catch (NullPointerException npe) {
19.System.out.println("NullPointerException");
20.}
21.}
What is the result?

Correct Answer: B
Question 5
Given:
1.package com.company.application;
2.3.
public class MainClass {
4.public static void main(String[] args) {}
5.} And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to "." (current directory).
Which two java commands entered at the command line will run MainClass? (Choose two.)

Correct Answer: A,F
Question 6
Given:
5.class Payload {
6.private int weight;
7.public Payload (int w) { weight = w; }
8.public void setWeight(int w) { weight = w; }
9.public String toString() { return Integer.toString(weight); }
10.}
11.public class TestPayload {
12.static void changePayload(Payload p) { /* insert code */ }
13.public static void main(String[] args) {
14.Payload p = new Payload(200);
15.p.setWeight(1024);
16.changePayload(p);
17.System.out.println("p is " + p);
18.} }
Which code fragment, inserted at the end of line 12, produces the output p is 420?

Correct Answer: D
Question 7
Given:
11.class X { public void foo() { System.out.print("X "); } }
12.13.
public class SubB extends X {
14.public void foo() throws RuntimeException {
15.super.foo();
16.if (true) throw new RuntimeException();
17.System.out.print("B ");
18.}
19.public static void main(String[] args) {
20.new SubB().foo();
21.}
22.}
What is the result?

Correct Answer: E
Question 8
DRAG DROP
Click the Task button.
Correct Answer:
Question 9
Which statement is true?

Correct Answer: C
Question 10
Given:
11.static class A {
12.void process() throws Exception { throw new Exception(); }
13.}
14.static class B extends A {
15.void process() { System.out.println("B"); }
16.}
17.public static void main(String[] args) {
18.new B().process();
19.}
What is the result?

Correct Answer: A