1z0-809 Training & Certification Get Latest Java SE Updated on Sep 29, 2021 [Q87-Q108]

Share

1z0-809 Training & Certification Get Latest Java SE Updated on Sep 29, 2021

Certification Training for 1z0-809 Exam Dumps Test Engine

NEW QUESTION 87
Which statement is true about java.util.stream.Stream?

  • A. A parallel stream is always faster than an equivalent sequential stream.
  • B. Streams are intended to modify the source data.
  • C. The execution mode of streams can be changed during processing.
  • D. A stream cannot be consumed more than once.

Answer: C

 

NEW QUESTION 88
Given:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
and the code fragment:
class App {
public void doRegister(String name, int age)
throws UserException, AgeOutOfLimitException {
if (name.length () < 6) {
throw new UserException ();
} else if (age >= 60) {
throw new AgeOutOfLimitException ();
} else {
System.out.println("User is registered.");
}
}
public static void main(String[ ] args) throws UserException {
App t = new App ();
t.doRegister("Mathew", 60);
}
}
What is the result?

  • A. An AgeOutOfLimitException is thrown.
  • B. A compilation error occurs in the main method.
  • C. User is registered.
  • D. A UserException is thrown.

Answer: A

 

NEW QUESTION 89
Given:

What is the result?

  • A. Compilation fails.
  • B. false false
  • C. true false
  • D. true true
  • E. false true

Answer: E

 

NEW QUESTION 90
Given the content of the employee.txtfile:
Every worker is a master.
Given that the employee.txtfile is accessible and the file allemp.txtdoes NOT exist, and the code fragment:

What is the result?

  • A. The program executes, does NOT affect the system, and produces NO output.
  • B. Exception 1
  • C. Exception 2
  • D. allemp.txt is created and the content of employee.txt is copied to it.

Answer: B

 

NEW QUESTION 91
Given the following classes:

And given the following main method:

Which two options fail to compile when placed at line n1 of the main method?

  • A. employee .budget = 200_000;
  • B. manager .stockoption = 500;
  • C. director .stockoptions = 1_000;
  • D. employee .salary = 50_000;
  • E. director .salary = 80_000;
  • F. manager .budget = 1_000_000;

Answer: A,B

 

NEW QUESTION 92
The protected modifier on a Field declaration within a public class means that the field
______________.

  • A. Can be read but not written from outside the class
  • B. Cannot be modified
  • C. Can be read and written from this class and its subclasses defined in any package
  • D. Can be read and written from this class and its subclasses only within the same package

Answer: C

Explanation:
http://beginnersbook.com/2013/05/java-access-modifiers/

 

NEW QUESTION 93
Given:
class UserException extends Exception { }
class AgeOutOfLimitException extends UserException { }
and the code fragment:
class App {
public void doRegister(String name, int age)
throws UserException, AgeOutOfLimitException {
if (name.length () < 6) {
throw new UserException ();
} else if (age >= 60) {
throw new AgeOutOfLimitException ();
} else {
System.out.println("User is registered.");
}
}
public static void main(String[ ] args) throws UserException {
App t = new App ();
t.doRegister("Mathew", 60);
}
}
What is the result?

  • A. User is registered.
  • B. An AgeOutOfLimitException is thrown.
  • C. A compilation error occurs in the main method.
  • D. A UserException is thrown.

Answer: A

 

NEW QUESTION 94
Given the code fragments:

and

What is the result?

  • A. DogCatMouse
  • B. [Dog, Cat, Mouse]
  • C. A compilation error occurs.
  • D. null

Answer: B

 

NEW QUESTION 95
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?

  • A. 100.12200.32
  • B. 200.12300.32
  • C. A compilation error occurs at line n2.
  • D. A compilation error occurs at line n1.

Answer: C

Explanation:

 

NEW QUESTION 96
Given:
class Worker extends Thread {
CyclicBarrier cb;
public Worker(CyclicBarrier cb) { this.cb = cb; }
public void run () {
try {
cb.await();
System.out.println("Worker...");
} catch (Exception ex) { }
}
}
class Master implements Runnable { //line n1
public void run () {
System.out.println("Master...");
}
}
and the code fragment:
Master master = new Master();
//line n2
Worker worker = new Worker(cb);
worker.start();
You have been asked to ensure that the run methods of both the Worker and Master classes are executed.
Which modification meets the requirement?

  • A. At line n2, insert CyclicBarrier cb = new CyclicBarrier(2, master);
  • B. At line n2, insert CyclicBarrier cb = new CyclicBarrier(master);
  • C. Replace line n1 with class Master extends Thread {
  • D. At line n2, insert CyclicBarrier cb = new CyclicBarrier(1, master);

Answer: C

 

NEW QUESTION 97
Given:

What is the result?

  • A. box
  • B. bo
  • C. nb
  • D. An exception is thrown at runtime
  • E. nbo

Answer: D

 

NEW QUESTION 98
Given:

What is the result?

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

Answer: A

 

NEW QUESTION 99
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 100
Given:
IntStream stream = IntStream.of (1,2,3);
IntFunction<Integer> inFu= x -> y -> x*y; //line n1
IntStream newStream = stream.map(inFu.apply(10)); //line n2
newStream.forEach(System.output::print);
Which modification enables the code fragment to compile?

  • A. Replace line n2with:
    IntStream newStream = stream.map(inFu.applyAsInt (10));
  • B. Replace line n1with:
    IntFunction<IntUnaryOperator> inFu = x -> y -> x*y;
  • C. Replace line n1with:
    BiFunction<IntUnaryOperator> inFu = x -> y -> x*y;
  • D. Replace line n1with:
    IntFunction<UnaryOperator> inFu = x -> y -> x*y;

Answer: A

 

NEW QUESTION 101
Given:

and

Which interface from the java.util.functionpackage should you use to refactor the class Txt?

  • A. Supplier
  • B. Predicate
  • C. Function
  • D. Consumer

Answer: A

 

NEW QUESTION 102
Given the code fragment:

What is the result?

  • A.
  • B. Javacourse
  • C. A compilation error occurs at line n1.
    courseJava
  • D. A compilation error occurs at line n2.

Answer: C

 

NEW QUESTION 103
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. An exception is thrown at line n1.
  • B. Travel time is 6 hours
  • C. Travel time is 4 hours
  • D. Travel time is 8 hours

Answer: C

 

NEW QUESTION 104
Given the content of the employee.txt file:
Every worker is a master.
Given that the employee.txt file is accessible and the file allemp.txt does NOT exist, and the code fragment:

What is the result?

  • A. The program executes, does NOT affect the system, and produces NO output.
  • B. Exception 1
  • C. Exception 2
  • D. allemp.txt is created and the content of employee.txt is copied to it.

Answer: B

 

NEW QUESTION 105
Given the code fragment:
Stream<Path> files = Files.list(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: B

 

NEW QUESTION 106

What is the result?

  • A. A compilation error occurs at line 7.
  • B. 0
  • C. A compilation error occurs at line 8.
  • D. A compilation error occurs at line 15.

Answer: A

 

NEW QUESTION 107
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

Explanation:
Explanation/Reference:

 

NEW QUESTION 108
......

Step by Step Guide to Prepare for 1z0-809 Exam: https://www.lead2passed.com/Oracle/1z0-809-practice-exam-dumps.html

Java SE 1z0-809 Real Exam Questions and Answers FREE Updated: https://drive.google.com/open?id=1C7VW9GqJir_q3cASqOLcOXCxLu3i0Trv