Real 1z0-809 are Uploaded by Exam4PDF provide 2021 Latest 1z0-809 Practice Tests Dumps.
All 1z0-809 Dumps and Java SE 8 Programmer II Training Courses Help candidates to study and pass the Java SE 8 Programmer II Exams hassle-free!
NEW QUESTION 13
The data.doc, data.txt and data.xml files are accessible and contain text.
Given the code fragment:
Stream<Path> paths = Stream.of (Paths. get("data.doc"),
Paths. get("data.txt"),
Paths. get("data.xml"));
paths.filter(s-> s.toString().endWith("txt")).forEach(
s -> {
try {
Files.readAllLines(s)
.stream()
.forEach(System.out::println); //line n1
} catch (IOException e) {
System.out.println("Exception");
}
}
);
What is the result?
- A. The program prints the content of the three files.
- B. The program prints:
Exception
<<The content of the data.txt file>>
Exception - C. A compilation error occurs at line n1.
- D. The program prints the content of data.txt file.
Answer: A
NEW QUESTION 14
Given the code fragment:
List<String> nL = Arrays.asList("Jim", "John", "Jeff");
Function<String, String> funVal = s -> "Hello : ".concat(s);
nL.Stream()
.map(funVal)
.forEach(s-> System.out.print (s));
What is the result?
- A. A compilation error occurs.
- B. Hello : Jim Hello : John Hello : Jeff
- C. The program prints nothing.
- D. Jim John Jeff
Answer: C
Explanation:
Explanation
The program prints nothing because the method is concat.
NEW QUESTION 15
Given the code fragments:
class Employee {
Optional<Address> address;
Employee (Optional<Address> address) {
this.address = address;
}
public Optional<Address> getAddress() { return address; }
}
class Address {
String city = "New York";
public String getCity { return city: }
public String toString() {
return city;
}
}
and
Address address = null;
Optional<Address> addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not available"; What is the result?
- A. New York
- B. null
- C. A NoSuchElementException is thrown at run time.
- D. City Not available
Answer: B
NEW QUESTION 16
Given the content of /resourses/Message.properties:
welcome1="Good day!"
and given the code fragment:
Properties prop = new Properties ();
FileInputStream fis = new FileInputStream ("/resources/Message.properties"); prop.load(fis); System.out.println(prop.getProperty("welcome1")); System.out.println(prop.getProperty("welcome2", "Test"));//line n1 System.out.println(prop.getProperty("welcome3")); What is the result?
- A. Good day!
Test
null - B. Good day!
followed by an Exception stack trace - C. Good day!
Test
followed by an Exception stack trace - D. A compilation error occurs at line n1.
Answer: A
NEW QUESTION 17
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?
- A. All files and directories under the home directory are listed along with their attributes.
- B. The files in the home directory are listed along with their attributes.
- C. A compilation error occurs at line n1.
- D. A compilation error occurs at line n2.
Answer: A
NEW QUESTION 18
Given the code fragment:
What is the result?
- A. 5 : 3 : 6
- B. 4 : 4 : 4
- C. 3 : 3 : 4
- D. 6 : 5 : 6
Answer: B
NEW QUESTION 19
Given the code fragments:
class MyThread implements Runnable {
private static AtomicInteger count = new AtomicInteger (0);
public void run () {
int x = count.incrementAndGet();
System.out.print (x+" ");
}
}
and
Thread thread1 = new Thread(new MyThread());
Thread thread2 = new Thread(new MyThread());
Thread thread3 = new Thread(new MyThread());
Thread [] ta = {thread1, thread2, thread3};
for (int x= 0; x < 3; x++) {
ta[x].start();
}
Which statement is true?
- A. A compilation error occurs.
- B. The program prints 1 2 3.
- C. The program prints 1 1 1.
- D. The program prints 1 2 3 and the order is unpredictable.
Answer: B
NEW QUESTION 20
Given the structure of the Student table:
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
Given the code fragment:
Assume that:
What is the result?
- A. The program prints Status: false and two records are deleted from the Student table.
- B. The program prints Status: false but the records from the Student table are not deleted.
- C. The program prints Status: true and two records are deleted from the Student table.
- D. A SQLException is thrown at runtime.
Answer: A
NEW QUESTION 21
Given:
and the code fragment:
What is the result?
- A. 0.0
- B. A compilation error occurs.
- C. 2000.0
- D. 1500.0
Answer: C
NEW QUESTION 22
Given that version.txtis accessible and contains:
1234567890
and given the code fragment:
What is the result?
121
- A.
- B. 0
- C. The program prints nothing.
- D. 1
Answer: B
NEW QUESTION 23
Given the code fragment:
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWordexists The Employeetable has a column ID of type integer and the SQL query matches one record.
What is the result?
- A. Compilation fails at line 15.
- B. Compilation fails at line 14.
- C. The code prints the employee ID.
- D. The code prints Error.
Answer: B
NEW QUESTION 24
Given the code fragment:
What is the result?
- A. 0
- B.
- C. A compilation error occurs at line n2.
3 - D. A compilation error occurs at line n1.
Answer: C
NEW QUESTION 25
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
- A. Path iP = new Paths ("/First.txt");
- B. Path iP = Paths.toPath ("/First.txt");
- C. Path iP = Paths.get ("/", "First.txt");
- D. Path iP = new Path ("/First.txt");
Answer: C
NEW QUESTION 26
Given the code fragments:
class Caller implements Callable<String> {
String str;
public Caller (String s) {this.str=s;}
public String call()throws Exception { return str.concat ("Caller");}
}
class Runner implements Runnable {
String str;
public Runner (String s) {this.str=s;}
public void run () { System.out.println (str.concat ("Runner"));}
}
and
public static void main (String[] args) InterruptedException, ExecutionException
{
ExecutorService es = Executors.newFixedThreadPool(2);
Future f1 = es.submit (new Caller ("Call"));
Future f2 = es.submit (new Runner ("Run"));
String str1 = (String) f1.get();
String str2 = (String) f2.get(); //line n1
System.out.println(str1+ ":" + str2);
}
What is the result?
- A. The program terminates after printing:
Run Runner
Call Caller : Run - B. The program prints:
Run Runner
Call Caller : null
And the program does not terminate. - C. An Execution is thrown at run time.
- D. A compilation error occurs at line n1.
Answer: B
NEW QUESTION 27
Given the code fragment:
What is the result?
- A. Compilation fails.
- B. 5 : 10
- C. 10 : 10
- D. 5 : 5
Answer: C
NEW QUESTION 28
Given the code fragment:
What is the result?
- A. 1000 : 2000
- B. 4000 : 2000
- C. 1000 : 4000
- D. 4000 : 1000
Answer: D
NEW QUESTION 29
Given the code fragment:
List<String> codes = Arrays.asList ("DOC", "MPEG", "JPEG");
codes.forEach (c -> System.out.print(c + " "));
String fmt = codes.stream()
.filter (s-> s.contains ("PEG"))
.reduce((s, t) -> s + t).get();
System.out.println("\n" + fmt);
What is the result?
- A. DOC MPEG JPEGMPEGJPEG
- B. MPEGJPEGMPEGJPEG
- C. The order of the output is unpredictable.
- D. DOC MPEG MPEGJPEGMPEGMPEGJPEG
Answer: A
NEW QUESTION 30
Given the definition of the Emp class:
public class Emp
private String eName;
private Integer eAge;
Emp(String eN, Integer eA) {
this.eName = eN;
this.eAge = eA;
}
public Integer getEAge () {return eAge;}
public String getEName () {return eName;}
}
and code fragment:
List<Emp>li = Arrays.asList(new Emp("Sam", 20), New Emp("John", 60), New Emp("Jim", 51)); Predicate<Emp> agVal = s -> s.getEAge() <= 60;//line n1 li = li.stream().filter(agVal).collect(Collectors.toList()); Stream<String> names = li.stream()map.(Emp::getEName);//line n2 names.forEach(n -> System.out.print(n + " ")); What is the result?
- A. John Jim
- B. A compilation error occurs at line n1.
- C. Sam John Jim
- D. A compilation error occurs at line n2.
Answer: B
NEW QUESTION 31
......
Valid Way To Pass Oracle's 1z0-809 Exam with : https://www.exam4pdf.com/1z0-809-dumps-torrent.html
Free Test Engine For Java SE 8 Programmer II Certification Exams: https://drive.google.com/open?id=1oS0cpN1B99N5wlEaciTCfpN6iFKHniif

