New Year Special 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: bestdeal

Free Oracle 1z0-809 Practice Exam with Questions & Answers | Set: 4

Questions 31

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?

Options:
A.

Good day!Testfollowed by an Exception stack trace

B.

Good day!followed by an Exception stack trace

C.

Good day!Testnull

D.

A compilation error occurs at line n1.

Oracle 1z0-809 Premium Access
Questions 32

1z0-809 Question 32

and the code fragment?

1z0-809 Question 32

What is the result?

Options:
A.

$15.00

B.

15 $

C.

USD 15.00

D.

USD $15

Questions 33

Which statement is true about the single abstract method of the java.util.function.Predicate interface?

Options:
A.

It accepts one argument and returns void.

B.

It accepts one argument and returns boolean.

C.

It accepts one argument and always produces a result of the same type as the argument.

D.

It accepts an argument and produces a result of any data type.

Questions 34

Given the content of Operator.java, EngineOperator.java, and Engine.java files:

1z0-809 Question 34

and the code fragment:

1z0-809 Question 34

What is the result?

Options:
A.

The Engine.java file fails to compile.

B.

The EngineOperator.java file fails to compile.

C.

The Operator.java file fails to compile.

D.

ON OFF

Questions 35

Given:

1z0-809 Question 35

and the code fragment:

1z0-809 Question 35

What is the result?

Options:
A.

A compilation error occurs at line n2.

B.

A compilation error occurs because the try block doesn’t have a catch or finally block.

C.

A compilation error occurs at line n1.

D.

The program compiles successfully.

Questions 36

Given the code fragments:

class Employee {

Optional

address;

Employee (Optional

address) {

this.address = address;

}

public Optional

getAddress() { return address; }

}

class Address {

String city = “New York”;

public String getCity { return city: }

public String toString() {

return city;

}

}

and

Address address = new Address;

Optional

addrs1 = Optional.ofNullable (address);

Employee e1 = new Employee (addrs1);

String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : “City Not

available”;

System.out.println(eAddress);

What is the result?

Options:
A.

New York

B.

City Not available

C.

null

D.

A NoSuchElementException is thrown at run time.

Questions 37

Given the code fragments:

1z0-809 Question 37

and

1z0-809 Question 37

What is the result?

Options:
A.

FranceOptional[NotFound]

B.

Optional [France]Optional [NotFound]

C.

Optional[France]Not Found

D.

FranceNot Found

Questions 38

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

Options:
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.

Questions 39

Given the code fragment:

1z0-809 Question 39

What is the result?

Options:
A.

4000 : 2000

B.

4000 : 1000

C.

1000 : 4000

D.

1000 : 2000

Questions 40

Given the code fragment:

Stream 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?

Options:
A.

All files and directories under the home directory are listed along with their attributes.

B.

A compilation error occurs at line n1.

C.

The files in the home directory are listed along with their attributes.

D.

A compilation error occurs at line n2.

Exam Code: 1z0-809
Certification Provider: Oracle
Exam Name: Java SE 8 Programmer II
Last Update: Feb 17, 2025
Questions: 196