Summer Special Flat 65% Limited Time Discount offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

Oracle 1z0-819 Java SE 11 Developer Exam Practice Test

Demo: 38 questions
Total 296 questions

Java SE 11 Developer Questions and Answers

Question 1

Given:

You want to obtain the Stream object on reading the file. Which code inserted on line 1 will accomplish this?

Options:

A.

var lines = Files.lines(Paths.get(INPUT_FILE_NAME));

B.

Stream lines = Files.readAllLines(Paths.get(INPUT_FILE_NAME));

C.

var lines = Files.readAllLines(Paths.get(INPUT_FILE_NAME));

D.

Stream lines = Files.lines(INPUT_FILE_NAME);

Question 2

Given:

Which statement on line 1 enables this code fragment to compile?

Options:

A.

Function function = String::toUpperCase;

B.

UnaryOperator function = s −> s.toUpperCase();

C.

UnaryOperator function = String::toUpperCase;

D.

Function function = m −> m.toUpperCase();

Question 3

Given the code fragment:

Which can replace line 2?

Options:

A.

UnaryOperator u = (int i) -> i * 2;

B.

UnaryOperator u = (var i) -> (i * 2);

C.

UnaryOperator u = var i -> { return i * 2; };

D.

UnaryOperator u = i -> { return i * 2);

Question 4

Given the content from the course.txt file:

Which code fragment at line 1 prints the lines that contain Java from the course.txt file?

A)

B)

C)

D)

E)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 5

Which two statements are true about Java modules? (Choose two.)

Options:

A.

Modular jars loaded from --module-path are automatic modules.

B.

Any named module can directly access all classes in an automatic module.

C.

Classes found in –classpath are part of an unnamed module.

D.

Modular jars loaded from –classpath are automatic modules.

E.

If a package is defined in both the named module and the unnamed module, then the package in the unnamed module is ignored.

Question 6

Given:

What is the result?

Options:

A.

b1

B.

2

C.

b2

D.

1

E.

b3

F.

3

G.

The compilation fails due to an error in line 1.

Question 7

Your organization provides a cloud server to your customer to run their Java code. You are reviewing the changes for the next release and you see this change in one of the config files:

Which is correct?

Options:

A.

You accept the change because -noverify is necessary for your code to run with the latest version of Java.

B.

You reject the change because -Xms8g -Xmx8g uses too much system memory.

C.

You accept the change because -noverify is a standard option that has been supported since Java 1.0.

D.

You reject the change because -noverify is a critical security risk.

Question 8

Given:

What is the result?

Options:

A.

385

B.

3

C.

The compilation fails.

D.

80

E.

25

Question 9

Given:

and

Which two method definitions at line n1 in the Bar class compile? (Choose two.)

Options:

A.

public List foo(Set m) {...}

B.

public List foo(Set m) {...}

C.

public List foo(TreeSet m) {...}

D.

public List foo(Set m) {...}

E.

public ArrayList foo(Set m) {...}

F.

public ArrayList foo(Set m) {...}

Question 10

Given:

You want to obtain the Filechannel object on line 1.

Which code fragment will accomplish this?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 11

Given:

List longlist = List.of(“Hello”,”World”,”Beat”);

List shortlist = new ArrayList<>();

Which code fragment correctly forms a short list of words containing the letter “e”?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 12

Given:

Assume the file on path does not exist. What is the result?

Options:

A.

The compilation fails.

B.

/u01/work/filestore.txt is not deleted.

C.

Exception

D.

/u01/work/filestore.txt is deleted.

Question 13

Given:

What is the result?

Options:

A.

abyssinian

oxicat

korat

laperm

bengal

sphynx

B.

abyssinian

bengal

korat

laperm

oxicat

sphynx

C.

sphynx

oxicat

laperm

korat

bengal

abyssinian

D.

nothing

Question 14

Given:

Which statement is true?

Options:

A.

Class Tester does not need to import java.time.LocalDate because it is already visible to members of the package test.

B.

All classes from the package java.time. are loaded for the class Diary.

C.

Only LocalDate class from java.time package is loaded.

D.

Tester must import java.time.LocalDate in order to compile.

Question 15

Given:

Taking into account that the order of the elements is unpredictable, what is the output?

Options:

A.

{am=2, first=1, mismatch=1, second=2}

B.

{mismatch=2, am=2, first=1, second=1}

C.

{l=mismatch, 2=am}

D.

{mismatch=1, am=2, first=1, second=1}

Question 16

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?

Options:

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 17

Given:

Which two statements can be added at line 1 in Bar to successfully compile it? (Choose two.)

Options:

A.

public List foo(Set m) { ... }

B.

public ArrayList foo(Set m) { ... }

C.

public List foo(TreeSet m) { ... }

D.

public List foo(Set m) { ... }

E.

public List foo(Set m) { ... }

F.

public ArrayList foo(Set m) { ... }

Question 18

Given:

You want to use the myResource class in a try-with-resources statement. Which change will accomplish this?

Options:

A.

Extend AutoCloseable and override the close method.

B.

Implement AutoCloseable and override the autoClose method.

C.

Extend AutoCloseable and override the autoClose method.

D.

Implement AutoCloseable and override the close method.

Question 19

Given:

What is the result?

Options:

A.

compilation error

B.

0 5

C.

6 13

D.

5 12

Question 20

Given:

What is the result?

Options:

A.

2,34,34,5

B.

2,34,54,5

C.

2,54,54,5

D.

2,34,54,3

Question 21

Given:

What is the result?

Options:

A.

42

B.

The compilation fails due to an error in line 4.

C.

17

D.

The compilation fails due to an error in line 3.

E.

The compilation fails due to an error in line 2.

F.

The compilation fails due to an error in line 1.

G.

The compilation fails due to an error in line 5.

Question 22

Given:

executed using command:

java Hello “Hello World” Hello World

What is the output?

Options:

A.

An exception is thrown at runtime.

B.

Hello WorldHello World

C.

Hello World Hello World

D.

Hello WorldHelloWorld

E.

HelloHello WorldHelloWorld

Question 23

Which two commands are used to identify class and module dependencies? (Choose two.)

Options:

A.

jmod describe

B.

java Hello.java

C.

jdeps --list-deps

D.

jar --show-module-resolution

E.

java --show-module-resolution

Question 24

What is the result?

Options:

A.

357

B.

35

C.

235

D.

2357

E.

An ArrayIndexOutOfBoundsException is thrown at runtime.

Question 25

Given:

After which line can we insert assert i < 0 || values[i] <= values[i + 1]; to verify that the

values array is partially sorted?

Options:

A.

after line 8

B.

after line 6

C.

after line 5

D.

after line 10

Question 26

Given:

You want to implement the java.io.Serializable interface to the MyPersistenceData class.

Which method should be overridden?

Options:

A.

the readExternal method

B.

nothing

C.

the readExternal and writeExternal method

D.

the writeExternal method

Question 27

Given:

Which annotation should be used to remove warnings from compilation?

Options:

A.

@SuppressWarnings on the main and print methods

B.

@SuppressWarnings(“unchecked”) on main and @SafeVarargs on the print method

C.

@SuppressWarnings(“rawtypes”) on main and @SafeVarargs on the print method

D.

@SuppressWarnings(“all”) on the main and print methods

Question 28

Given the code fragment:

What is the result?

Options:

A.

1

B.

The compilation fails at line

C.

10

D.

The compilation fails at line 16.

E.

The compilation fails at line 13.

Question 29

Given:

Which two method implementations are correct, when inserted independently in line 1? (Choose two.)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

Question 30

Given:

What is the result?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 31

Given:

What is the result?

Options:

A.

Good Morning, Potter

B.

Good Night, Potter

C.

Good Morning, Harry

D.

Good Night, Harry

Question 32

Given:

Which is true?

Options:

A.

The compilation fails due to an error in line 6.

B.

The compilation succeeds.

C.

The compilation fails due to an error in line 4.

D.

The compilation fails due to an error in line 10.

E.

The compilation fails due to an error in line 7.

F.

The compilation fails due to an error in line 9.

G.

The compilation fails due to an error in line 2.

Question 33

Given:

Which statement is equivalent to line 1?

Options:

A.

double totalSalary = list.stream().map(e −> e.getSalary() * ratio).reduce (bo).ifPresent (p −> p.doubleValue());

B.

double totalSalary = list.stream().mapToDouble(e −> e.getSalary() * ratio).sum;

C.

double totalSalary = list.stream().map(Employee::getSalary * ratio).reduce (bo).orElse(0.0);

D.

double totalSalary = list.stream().mapToDouble(e −> e.getSalary() * ratio).reduce(starts, bo);

Question 34

Given:

/code/a/Test.java

containing:

and

/code/b/Best.java

containing:

package b;

public class Best { }

Which is the valid way to generate bytecode for all classes?

Options:

A.

java /code/a/Test.java

B.

javac –d /code /code/a/Test

C.

java /code/a/Test.java /code/b/Best.java

D.

java –cp /code a.Test

E.

javac –d /code /code/a/Test.java /code/b/Best.java

F.

javac –d /code /code/a/Test.java

Question 35

Which code fragment added to line 1 enables the code to compile and print Hello Joe?

A)

B)

C)

D)

Options:

Question 36

A company has an existing sales application using a Java 8 jar file containing packages:

com.company.customer;

com.company.customer.orders;

com.company.customer.info;

com.company.sales;

com.company.sales.leads;

com.company.sales.closed;

com.company.orders;

com.company.orders.pending;

com.company.orders.shipped.

To modularize this jar file into three modules, customer, sales, and orders, which module-info.java would be correct?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 37

Given:

What is the result?

Options:

A.

[A, B, C]

followed by an exception thrown on line 11.

B.

[A, B, C]

[A, B]

C.

[A, B, C]

[A, B, C]

D.

On line 9, an exception is thrown at run time.

Question 38

Given the code fragment:

Which two statement inserted independently at line 1 enable this code to print PRRT?

Options:

A.

i—;

B.

continue b;

C.

break b;

D.

j--;

E.

continue a;

F.

break a ;

Demo: 38 questions
Total 296 questions