Exit demo 1Z0-816 Java SE 11 Programmer II PDF format · free preview

Oracle 1Z0-816 - Questions & Answers

Free preview · every answer includes a full explanation

Product page: https://prepkeys.com/1z0-816.html

Question 1
Single choice

Given the code fragment:

Path currentFile = Paths.get("/scratch/exam/temp.txt");
Path outputFile = Paths get("/scratch/exam/new.txt");
Path directory = Paths.get("/scratch/");

Files.copy(currentFile, outputFile);
Files.copy(outputFile, directory);
Files.delete (outputFile);

The /scratch/exam/temp.txt file exists. The /scratch/exam/new.txt and /scratch/new.txt files do not exist.

What is the result?

A.

/scratch/exam/new.txt and /scratch/new.txt are deleted.

B.

The program throws a FileaAlreadyExistsException.

C.

The program throws a NoSuchFileException.

D.

A copy of /scratch/exam/new.txt exists in the /scratch directory and /scratch/exam/new.txt is deleted.

Question 2
Multiple choice

Which two are functional interfaces? (Choose two.)

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 3
Multiple choice

Given the declaration:

Examine this code fragment:

/* Loc1 */ class ProcessOrders { ... }

Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)

A.

@Resource(priority=100)

B.

@Resource(priority=0)

C.

@Resource(name="Customer1", priority=100)

D.

@Resource(name="Customer1")

E.

@Resource

Question 4
Multiple choice

Given:

Which two interfaces can be used in lambda expressions? (Choose two.)

A.

MyInterface1

B.

MyInterface3

C.

MyInterface5

D.

MyInterface2

E.

MyInterface4

Question 5
Single choice

Given this enum declaration:

Examine this code:

System.out.println(Alphabet.getFirstLetter());

What code should be written at line 3 to make this code print A?

A.

final String getFirstLetter() { return A.toString(); }

B.

static String getFirstLetter() { return Alphabet.values()[1].toString(); }

C.

static String getFirstLetter() { return A.toString(); }

D.

String getFirstLetter() { return A.toString(); }

Question 6
Single choice

Given these two classes:

And given this fragment:

Which describes the fragment?

A.

It throws IllegalMonitorStateException.

B.

It is subject to deadlock.

C.

It is subject to livelock.

D.

The code does not compile.

Question 7
Single choice

Given:

Examine these requirements:

Eliminate code duplication.
Keep constant the number of methods other classes may implement from this interface.

Which method can be added to meet these requirements?

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 8
Single choice

Given:

Which one is correct?

A.

An IllegalThreadStateException is thrown at run time.

B.

Three threads are created.

C.

The compilation fails.

D.

Four threads are created.

Question 9
Single choice

Which code fragment does a service use to load the service provider with a Print interface?

A.

private Print print = com.service.Provider.getInstance();

B.

private java.util.ServiceLoader<Print> loader = ServiceLoader.load(Print.class);

C.

private java.util.ServiceLoader<Print> loader = new java.util.ServiceLoader<>();

D.

private Print print = new com.service.Provider.PrintImpl();

Question 10
Multiple choice

Examine these module declarations:

Which two statements are correct? (Choose two.)

A.

The ServiceProvider module is the only module that, at run time, can provide the com.example.api API.

B.

The placement of the com.example.api API in a separate module, ServiceAPI, makes it easy to install

multiple provider modules.

C.

The Consumer module should require the ServiceProvider module.

D.

The ServiceProvider module should export the com.myimpl package.

E.

The ServiceProvider module does not know the identity of a module (such as Consumer) that uses the
com.example.api API.

Showing 10 of 80 questions · Unlock the full set