Oracle Java SE 8 Programmer II - 1z1-809 Exam Practice Test

Question 1
Given:
public final class IceCream {
public void prepare() {}
}
public class Cake {
public final void bake(int min, int temp) {}
public void mix() {}
}
public class Shop {
private Cake c = new Cake ();
private final double discount = 0.25;
public void makeReady () { c.bake(10, 120); }
}
public class Bread extends Cake {
public void bake(int minutes, int temperature) {}
public void addToppings() {}
}
Which statement is true?

Correct Answer: E
Question 2
Given:

From what threading problem does the program suffer?

Correct Answer: B
Question 3
Given the code fragment:

What is the result?

Correct Answer: C
Question 4
Given the code fragment:

What is the result?

Correct Answer: B
Question 5
Given the code fragment:

What is the result?

Correct Answer: A
Question 6
Which two are elements of a singleton class? (Choose two.)

Correct Answer: B,E
Question 7
Given the code fragment:
BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1
//line n2
System.out.println(val.apply(10, 10.5));
What is the result?

Correct Answer: D
Question 8
Given the code fragment:
List<Double> doubles = Arrays.asList (100.12, 200.32);
DoubleFunction funD = d -> d + 100.0;
doubles.stream (). forEach (funD); // line n1
doubles.stream(). forEach(e -> System.out.println(e)); // line n2
What is the result?

Correct Answer: D
Explanation: Only visible for Actualtests4sure members. You can sign-up / login (it's free).
Question 9
Given the code fragment:
Stream<Path> files = Files.walk(Paths.get(System.getProperty("user.home"))); files.forEach (fName -> {//line n1 try { Path aPath = fName.toAbsolutePath();//line n2 System.out.println(fName + ":"
+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime ());
} catch (IOException ex) {
ex.printStackTrace();
});
What is the result?

Correct Answer: A
Question 10
Given:
public class Canvas implements Drawable {
public void draw () { }
}
public abstract class Board extends Canvas { }
public class Paper extends Canvas {
protected void draw (int color) { }
}
public class Frame extends Canvas implements Drawable {
public void resize () { }
}
public interface Drawable {
public abstract void draw ();
}
Which statement is true?

Correct Answer: D
Question 11
Given:

and the code fragment:

What is the result?

Correct Answer: D
Explanation: Only visible for Actualtests4sure members. You can sign-up / login (it's free).
Question 12
Given the definition of the Book class:

Which statement is true about the Book class?

Correct Answer: B
Question 13
Given the code fragment:
List<String> listVal = Arrays.asList("Joe", "Paul", "Alice", "Tom");
System.out.println (
// line n1
);
Which code fragment, when inserted at line n1, enables the code to print the count of string elements whose length is greater than three?

Correct Answer: C
Question 14
Given the content of resources /Message.properties:
greet = Good Day!
Given the content of resources/Message_de_DE.properties:
greet = Guten Tag!
Given the code fragment from C:\src\App.java:

Correct Answer: D
Question 15
Given the code fragment:
LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14);
LocalDate next15days = valentinesDay.plusDays (15);
LocalDate nextYear = next15days.plusYears(1); // line n1
System.out.println(nextYear);
What is the result?

Correct Answer: D