web analytics

100% Pass Ensure 1Z0-809 Dumps with Free VCE and PDF (Question 11 – Question 20)

PassLeader now are offering 100% pass ensure 1Z0-809 dumps! All 1Z0-809 exam questions have been updated with correct answers, welcome to download the newest PassLeader 1Z0-809 VCE dumps and PDF dumps: https://www.passleader.com/1z0-809.html (132 Q&As)

BTW: Download PassLeader 1Z0-809 dumps from Google Drive for free: https://drive.google.com/open?id=0B-ob6L_QjGLpNTlzOWE4bXRKMmM

QUESTION 11
Given the code fragment:
public class FileThread implements Runnable {
String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException {
ExecutorService executor = Executors.newCachedThreadPool();
Stream<Path> listOfFiles = Files.walk(Paths.get(“Java Projects”));
listOfFiles.forEach(line -> {
executor.execute(new FileThread(line.getFileName().toString()));//line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS);//line n2
}
}
The Java Projects directory exists and contains a list of files. What is the result?

A.    The program throws a runtime exception at line n2.
B.    The program prints files names concurrently.
C.    The program prints files names sequentially.
D.    A compilation error occurs at line n1.

Answer: A

QUESTION 12
Given:
final class Folder {//line n1
//line n2
public void open () {
System.out.print(“Open”);
}
}
public class Test {
public static void main (String [] args) throws Exception {
try (Folder f = new Folder()) {
f.open();
}
}
}
Which two modifications enable the code to print Open Close? (Choose two.)

A.    Replace line n1 with:
class Folder implements AutoCloseable {
B.    Replace line n1 with:
class Folder extends Closeable {
C.    Replace line n1 with:
class Folder extends Exception {
D.    At line n2, insert:
final void close () {
System.out.print(“Close”);
}
E.    At line n2, insert:
public void close () throws IOException {
System.out.print(“Close”);
}

Answer: AC

QUESTION 13
Given the code fragment:
List<Integer> codes = Arrays.asList (10, 20);
UnaryOperator<Double> uo = s -> s +10.0;
codes.replaceAll(uo);
codes.forEach(c -> System.out.println(c));
What is the result?

A.    20.0
30.0
B.    10
C.    A compilation error occurs
D.    A NumberFormatException is thrown at run time

Answer: A

QUESTION 14
Given:
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn;
lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
and the code fragment:
List<Emp> emp = Arrays.asList (
new Emp (“John”, “Smith”),
new Emp (“Peter”, “Sam”),
new Emp (“Thomas”, “Wale”));
emp.stream()
//line n1
.collect(Collectors.toList());
Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName?

A.    .sorted(Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName))
B.    .sorted(Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))
C.    .map(Emp::getfName).sorted(Comparator.reserveOrder())
D.    .map(Emp::getfName).sorted(Comparator.reserveOrder().map(Emp::getlName).reserved

Answer: A

QUESTION 15
Given:
interface Rideable {Car getCar (String name); }
class Car {
private String name;
public Car (String name) {
this.name = name;
}
}
Which code fragment creates an instance of Car?

A.    Car auto = Car (“MyCar”): : new;
B.    Car auto = Car : : new;
Car vehicle = auto : : getCar(“MyCar”);
C.    Rideable rider = Car : : new;
Car vehicle = rider.getCar(“MyCar”);
D.    Car vehicle = Rideable : : new : : getCar(“MyCar”);

Answer: C

QUESTION 16
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?

A.    A compilation error occurs in IceCream.
B.    A compilation error occurs in Cake.
C.    A compilation error occurs in Shop.
D.    A compilation error occurs in Bread.
E.    All classes compile successfully.

Answer: D

QUESTION 17
You want to create a singleton class by using the Singleton design pattern. Which two statements enforce the singleton nature of the design? (Choose two.)

A.    Make the class static.
B.    Make the constructor private.
C.    Override equals() and hashCode() methods of the java.lang.Object class.
D.    Use a static reference to point to the single instance.
E.    Implement the Serializable interface.

Answer: AB

QUESTION 18
You have been asked to create a ResourceBundle which uses a properties file to localize an application. Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?

A.    <key name = “menu1”>File Menu</key>
<key name = “menu2”>View Menu</key>
B.    <key>menu1</key><value>File Menu</value>
<key>menu2</key><value>View Menu</value>
C.    menu1, File Menu, menu2, View Menu
D.    menu1 = File Menu
menu2 = View Menu

Answer: B

QUESTION 19
Given the code fragment:
public class StringReplace {
public static void main(String[] args) {
String message = “Hi everyone!”;
System.out.println(“message = ” + message.replace(“e”, “X”)); }
}
What is the result?

A.    message = Hi everyone!
B.    message = Hi XvXryonX!
C.    A compile time error is produced.
D.    A runtime error is produced.
E.    message = Hi Xveryone!

Answer: B

QUESTION 20
Given the code fragment:
UnaryOperator<Integer> uo1 = s -> s*2;//line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + ” “));//line n2
What is the result?

A.    4000.0
B.    4000
C.    A compilation error occurs at line n1
D.    A compilation error occurs at line n2

Answer: B


PassLeader now are offering 100% pass ensure 1Z0-809 dumps! All 1Z0-809 exam questions have been updated with correct answers, welcome to download the newest PassLeader 1Z0-809 VCE dumps and PDF dumps: https://www.passleader.com/1z0-809.html (132 Q&As)

BTW: Download PassLeader 1Z0-809 dumps from Google Drive for free: https://drive.google.com/open?id=0B-ob6L_QjGLpNTlzOWE4bXRKMmM