Given:
11.
public static void parse(String str) {
12.
try {
13.
float f = Float.parseFloat(str);
14.
} catch (NumberFormatException nfe) {
15.
f = 0;
16.
} finally {
17.
System.out.println(f);
18.
}
19.
}
20.
public static void main(String[] args) {
21.
parse("invalid");
22.
}
What is the result?
A. 0.0Given:
1.
import java.util.*;
2.
public class Example {
3.
public static void main(String[] args) {
4.
// insert code here
5.
set.add(new Integer(2));
6.
set.add(new Integer(1));
7.
System.out.println(set);
8.
}
9.
}
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
A. Set set = new TreeSet();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?
A. BClick the Exhibit button. Given:
25.
try {
26.
A a = new A();
27.
a.method1();
28.
} catch (Exception e) {
29.
System.out.print("an error occurred");
30.
}
Which two statements are true if a NullPointerException is thrown on line 3 of class C? (Choose two.)

Which statement is true?
A. A class's finalize() method CANNOT be invoked explicitly.Given:
1.
public class Donkey {
2.
public static void main(String[] args) {
3.
boolean assertsOn = false;
4.
assert (assertsOn) : assertsOn = true;
5.
if(assertsOn) {
6.
System.out.println("assert is on");
7.
}
8.
}
9.
}
If class Donkey is invoked twice, the first time without assertions enabled, and the second time with assertions enabled, what are the results?
A. no outputGiven:
3.
interface Fish { }
4.
class Perch implements Fish { }
5.
class Walleye extends Perch { }
6.
class Bluegill { }
7.
public class Fisherman {
8.
public static void main(String[] args) {
9.
Fish f = new Walleye();
10.
Walleye w = new Walleye();
11.
Bluegill b = new Bluegill();
12.
if(f instanceof Perch) System.out.print("f-p ");
13.
if(w instanceof Fish) System.out.print("w-f ");
14.
if(b instanceof Fish) System.out.print("b-f ");
15.
}
16.
}
What is the result?
A. w-fGiven:
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?
A. TeaGiven:
10.
class One {
11.
void foo() { }
12.
}
13.
class Two extends One {
14.
//insert method here
15.
}
Which three methods, inserted individually at line 14, will correctly complete class Two? (Choose three.)
A. int foo() { /* more code here */ }Given:
1.
interface TestA { String toString(); }
2.
public class Test {
3.
public static void main(String[] args) {
4.
System.out.println(new TestA() {
5.
public String toString() { return "test"; }
6.
});
7.
}
8.
}
What is the result?
A. testNowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Oracle exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your 1Z0-851 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.