Free 2021 Java SE 1z0-809 dumps are available by TroytecDumps [Q28-Q53]

Share

Free 2021 Java SE 1z0-809 dumps are available on Google Drive shared by TroytecDumps

Welcome to download the newest TroytecDumps 1z0-809 PDF dumps: https://www.troytecdumps.com/1z0-809-troytec-exam-dumps.html ( 195  Q&As)

NEW QUESTION 28
Given the code fragment:

Which code fragment, when inserted at line 7, enables printing 100?

  • A. ToIntFunction<Integer> funRef = e -> e + 10;
    int result = funRef.applyAsInt (value);
  • B. ToIntFunction funRef = e -> e + 10;
    int result = funRef.apply (value);
  • C. IntFunction funRef = e -> e + 10;
    Integer result = funRef.apply (10);
  • D. Function<Integer> funRef = e -> e + 10;
    Integer result = funRef.apply(value);

Answer: D

 

NEW QUESTION 29
Given:

Which two interfaces can you use to create lambda expressions?

  • A. U
  • B. Q
  • C. S
  • D. T
  • E. P
  • F. R

Answer: A,D

 

NEW QUESTION 30
Given the definition of the Employee class:

and this code fragment:

What is the result?

  • A. [sales:Ada, hr:Bob, sales:Bob, hr:Eva]
  • B. [hr:Eva, hr:Bob, sales:Bob, sales:Ada]
  • C. [hr:Bob, hr:Eva, sales:Ada, sales:Bob]
  • D. [Ada:sales, Bob:sales, Bob:hr, Eva:hr]

Answer: A

 

NEW QUESTION 31
Given the code fragments:
public class Book implements Comparator<Book> {
String name;
double price;
public Book () {}
public Book(String name, double price) {
this.name = name;
this.price = price;
}
public int compare(Book b1, Book b2) {
return b1.name.compareTo(b2.name);
}
public String toString() {
return name + ":" + price;
}
}
and
List<Book>books = Arrays.asList (new Book ("Beginning with Java", 2),
new book ("A
Guide to Java Tour", 3));
Collections.sort(books, new Book());
System.out.print(books);
What is the result?

  • A. [A Guide to Java Tour:3, Beginning with Java:2]
  • B. An Exception is thrown at run time.
  • C. [Beginning with Java:2, A Guide to Java Tour:3]
  • D. A compilation error occurs because the Book class does not override the abstract method compareTo().

Answer: A

 

NEW QUESTION 32
Which two reasons should you use interfaces instead of abstract classes? (Choose two.)

  • A. You want to share code among several closely related classes.
  • B. You want to declare non-static on non-final fields.
  • C. You expect that classes that implement your interfaces have many common methods or fields, or require access modifiers other than public.
  • D. You want to take advantage of multiple inheritance of type.
  • E. You expect that unrelated classes would implement your interfaces.

Answer: D,E

 

NEW QUESTION 33
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. 0
  • B. A compilation error occurs.
  • C. 20.0
    30.0
  • D. A NumberFormatExceptionis thrown at run time.

Answer: C

 

NEW QUESTION 34
Given the code fragment:
Path file = Paths.get ("courses.txt");
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

  • A. Stream<String> fc = Files.lines (file);fc.forEach (s - > System.out.println(s));
  • B. Stream<String> fc = Files.readAllLines (file);fc.forEach (s - > System.out.println(s));
  • C. List<String> fc = readAllLines(file);fc.stream().forEach (s - > System.out.println(s));
  • D. List<String> fc = Files.list(file);fc.stream().forEach (s - > System.out.println(s));

Answer: A

 

NEW QUESTION 35
Given the code fragment:
ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of ( "UTC-7"));
ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of ( "UTC-5"));
long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1
System.out.println("Travel time is" + hrs + "hours");
What is the result?

  • A. Travel time is 6 hours
  • B. Travel time is 8 hours
  • C. An exception is thrown at line n1.
  • D. Travel time is 4 hours

Answer: C

 

NEW QUESTION 36
Assume customers.txt is accessible and contains multiple lines.
Which code fragment prints the contents of the customers.txt file?

  • A. Stream<Path> stream = Files.find (Paths.get ("customers.txt"));
    stream.forEach( c) -> System.out.println(c));
  • B. Stream<Path> stream = Files.list (Paths.get ("customers.txt"));
    stream.forEach( c) -> System.out.println(c));
  • C. Stream<String> lines = Files.lines (Paths.get ("customers.txt"));
    lines.forEach( c) -> System.out.println(c));
  • D. Stream<String> stream = Files.find (Paths.get ("customers.txt"));
    stream.forEach((String c) -> System.out.println(c));

Answer: D

 

NEW QUESTION 37
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() > 50;//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. Sam John Jim
  • C. A compilation error occurs at line n1.
  • D. A compilation error occurs at line n2.

Answer: B

 

NEW QUESTION 38
Given that these files exist and are accessible:
/sports/info.txt
/sports/cricket/players.txt
/sports/cricket/data/ODI.txt
and given the code fragment:
int maxDepth =2;
Stream<Path> paths = Files.find(Paths.get("/sports"),
maxDepth,
(p, a) -> p.getFileName().toString().endsWith ("txt"),
FileVisitOption.FOLLOW_LINKS);
Long fCount = paths.count();
System.out.println(fCount);
Assuming that there are NO soft-link/symbolic links to any of the files in the directory structure, what is the result?

  • A. 0
  • B. 1
  • C. An Exception is thrown at runtime.
  • D. 2

Answer: C

 

NEW QUESTION 39
Given:

What is the result?

  • A. false, true
  • B. false, false
  • C. true, false
  • D. true, true

Answer: A

 

NEW QUESTION 40
Given:
class Student {
String course, name, city;
public Student (String name, String course, String city) {
this.course = course; this.name = name; this.city = city;
}
public String toString() {
return course + ":" + name + ":" + city;
}
public String getCourse() {return course;}
public String getName() {return name;}
public String getCity() {return city;}
and the code fragment:
List<Student> stds = Arrays.asList(
new Student ("Jessy", "Java ME", "Chicago"),
new Student ("Helen", "Java EE", "Houston"),
new Student ("Mark", "Java ME", "Chicago"));
stds.stream()
.collect(Collectors.groupingBy(Student::getCourse))
.forEach(src, res) -> System.out.println(scr));
What is the result?

  • A. Java ME
    [Java EE: Helen:Houston]
  • B. [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
    [Java ME: Jessy:Chicago, Java ME: Mark:Chicago]
  • C. A compilation error occurs.
    Java EE
  • D. [Java EE: Helen:Houston]

Answer: A

 

NEW QUESTION 41
Given:
public interface Moveable<Integer> {
public default void walk (Integer distance) {System.out.println("Walking");) public void run(Integer distance);
}
Which statement is true?

  • A. Movable cannot be used in a lambda expression.
  • B. Moveable can be used as below:
    Moveable<Integer> animal = n - > n + 10;
    animal.run(100);
    animal.walk(20);
  • C. Moveable can be used as below:
    Moveable animal = (Integer n) - > System.out.println(n);
    animal.run(100);
    Moveable.walk(20);
  • D. Moveable can be used as below:
    Moveable<Integer> animal = n - > System.out.println("Running" + n);
    animal.run(100);
    animal.walk(20);

Answer: D

 

NEW QUESTION 42
Given the code fragment:

Which two modifications, when made independently, enable the code to print Joe:true:100.0?

  • A. Option A
  • B. Option D
  • C. Option C
  • D. Option B
  • E. Option E

Answer: A,C

 

NEW QUESTION 43
Given the code fragment:

What is the result?

  • A. Compilation fails.
  • B. 1 3
    1 3
  • C. 1 3
    1 3 0 0
  • D. 1 3
    followed by an ArrayIndexOutOfBoundsException
  • E. 1 3 5 7
    1 3

Answer: E

 

NEW QUESTION 44
Given:

and the code fragment:

Which two code fragments, when inserted at line n1independently, enable the code to print TruckCarBike?

  • A. .sorted (Comparable.comparing (Vehicle: :getVName)).reversed ()
  • B. .sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid()))
  • C. .sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))
  • D. .map (v -> v.getVid())
    .sorted ()
  • E. .sorted ((v1, v2) -> v1.getVId() < v2.getVId())

Answer: B

 

NEW QUESTION 45
Given the code fragment:
Path source = Paths.get ("/data/december/log.txt");
Path destination = Paths.get("/data");
Files.copy (source, destination);
and assuming that the file /data/december/log.txt is accessible and contains:
10-Dec-2014 - Executed successfully
What is the result?

  • A. A FileNotFoundException is thrown at run time.
  • B. The program executes successfully and does NOT change the file system.
  • C. A file with the name log.txt is created in the /data directory and the content of the /data/december/log.txt
    file is copied to it.
  • D. A FileAlreadyExistsException is thrown at run time.

Answer: D

 

NEW QUESTION 46
Given:
class ImageScanner implements AutoCloseable {
public void close () throws Exception {
System.out.print ("Scanner closed.");
}
public void scanImage () throws Exception {
System.out.print ("Scan.");
throw new Exception("Unable to scan.");
}
}
class ImagePrinter implements AutoCloseable {
public void close () throws Exception {
System.out.print ("Printer closed.");
}
public void printImage () {System.out.print("Print."); }
}
and this code fragment:
try (ImageScanner ir = new ImageScanner();
ImagePrinter iw = new ImagePrinter()) {
ir.scanImage();
iw.printImage();
} catch (Exception e) {
System.out.print(e.getMessage());
}
What is the result?

  • A. Scan. Unable to scan.
  • B. Scan.Scanner closed. Unable to scan.
  • C. Scan. Unable to scan. Printer closed.
  • D. Scan.Printer closed. Scanner closed. Unable to scan.

Answer: D

 

NEW QUESTION 47
Given:
1. abstract class Shape {
2. Shape ( ) { System.out.println (“Shape”); }
3. protected void area ( ) { System.out.println (“Shape”); }
4. }
5.
6. class Square extends Shape {
7. int side;
8. Square int side {
9. /* insert code here */
10. this.side = side;
11. }
12. public void area ( ) { System.out.println (“Square”); }
13. }
14. class Rectangle extends Square {
15. int len, br;
16. Rectangle (int x, int y) {
17. /* insert code here */
18. len = x, br = y;
19. }
20. void area ( ) { System.out.println (“Rectangle”); }
21. }
Which two modifications enable the code to compile?

  • A. At line 17, insert super (); super.side = x;
  • B. At line 17, insert super (x);
  • C. At line 12, remove public
  • D. At line 9, insert super ( );
  • E. At line 20, use public void area ( ) {
  • F. At line 1, remove abstract

Answer: B,E

 

NEW QUESTION 48
Given the code fragment:
Path source = Paths.get ("/data/december/log.txt");
Path destination = Paths.get("/data");
Files.copy (source, destination);
and assuming that the file /data/december/log.txt is accessible and
contains:
10-Dec-2014 ?Executed successfully
What is the result?

  • A. A FileNotFoundException is thrown at run time.
  • B. The program executes successfully and does NOT change the file system.
  • C. A file with the name log.txt is created in the /data directory and the content of the
    /data/december/log.txt file is copied to it.
  • D. A FileAlreadyExistsException is thrown at run time.

Answer: D

 

NEW QUESTION 49
Given the code fragments:
class TechName {
String techName;
TechName (String techName) {
this.techName=techName;
}
}
and
List<TechName> tech = Arrays.asList (
new TechName("Java-"),
new TechName("Oracle DB-"),
new TechName("J2EE-")
);
Stream<TechName> stre = tech.stream();
//line n1
Which should be inserted at line n1 to print Java-Oracle DB-J2EE-?

  • A. stre.forEachOrdered(System.out::print);
  • B. stre.map(a-> a).forEachOrdered(System.out::print);
  • C. stre.forEach(System.out::print);
  • D. stre.map(a-> a.techName).forEach(System.out::print);

Answer: D

 

NEW QUESTION 50
Given the code fragment:

What is the result?

  • A. 0 2 4 6
  • B. 2 4
    Compilation fails.
  • C. 0 2 4

Answer: C

 

NEW QUESTION 51
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 52
Given the code fragment:

What is the result?

  • A. An exception is thrown at runtime.
  • B. May 04, 2014T00:00:00.000
  • C. 2014-05-04T00:00.000
  • D. 5/4/14T00:00:00.000

Answer: A

 

NEW QUESTION 53
......

Tested Material Used To 1z0-809: https://www.troytecdumps.com/1z0-809-troytec-exam-dumps.html

Following are some new 1z0-809 Real Exam Questions!: https://drive.google.com/open?id=1vE13wV7E_ImIQjet-XJq2DeoWdKKS9Cg