Given:
1.
public class TestString1 {
2.
public static void main(String[] args) {
3.
String str = "420";
4.
str += 42;
5.
System.out.print(str);
6.
}
7.
}
What is the output?
A. 42Given:
11.
public class Rainbow {
12.
public enum MyColor {
13.
RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff);
14.
private final int rgb;
15.
MyColor(int rgb) { this.rgb = rgb; }
16.
public int getRGB() { return rgb; }
17.
};
18.
public static void main(String[] args) {
19.
// insert code here
20.
}
21.
}
Which code fragment, inserted at line 19, allows the Rainbow class to compile?
A. MyColor skyColor = BLUE;Given
11.
public interface Status {
12.
/* insert code here */ int MY_VALUE = 10;
13.
}
Which three are valid on line 12? (Choose three.)
A. finalGiven:
1.
class Pizza {
2.
java.util.ArrayList toppings;
3.
public final void addTopping(String topping) {
4.
toppings.add(topping);
5.
}
6.
}
7.
public class PepperoniPizza extends Pizza {
8.
public void addTopping(String topping) {
9.
System.out.println("Cannot add Toppings");
10.
}
11.
public static void main(String[] args) {
12.
Pizza pizza = new PepperoniPizza();
13.
pizza.addTopping("Mushrooms");
14.
}
15.
}
What is the result?

Given:
3.
import java.util.*;
4.
public class Hancock {
5.
// insert code here
6.
list.add("foo");
7.
}
8.
}
Which two code fragments, inserted independently at line 5, will compile without warnings? (Choose two.)
A. public void addStrings(List list) {Which two scenarios are NOT safe to replace a StringBuffer object with a StringBuilder object? (Choose two.)
A. When using versions of Java technology earlier than 5.0.Given:
11 class Alpha {
12 public void foo() { System.out.print("Afoo "); } 13 }
14 public class Beta extends Alpha {
15 public void foo() { System.out.print("Bfoo "); } 16 public static void main(String[] args) {
17 Alpha a = new Beta();
18 Beta b = (Beta)a;
19 a.foo();
20 b.foo();
21 }
22 }
What is the result?
A. Afoo AfooGiven:
31.
// some code here
32.
try {
33.
// some code here
34.
} catch (SomeException se) {
35.
// some code here
36.
} finally {
37.
// some code here
38.
}
Under which three circumstances will the code on line 37 be executed? (Choose three.)
A. The instance gets garbage collected.Given a class Repetition:
1.
package utils;
2.
3.
public class Repetition {
4.
public static String twice(String s) { return s + s; }
5.
} and given another class Demo: 1. // insert code here 2.
3.
public class Demo {
4.
public static void main(String[] args) {
5.
System.out.println(twice("pizza"));
6.
}
7.
}
Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?
A. import utils.*;Given:
1.
public class LineUp {
2.
public static void main(String[] args) {
3.
double d = 12.345;
4.
// insert code here
5.
}
6.
}
Which code fragment, inserted at line 4, produces the output | 12.345|?
A. System.out.printf("|%7d| \n", d);Nowadays, 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.