Weekend Sale Special Limited Time 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

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

Page: 1 / 26
Total 257 questions

Java SE 11 Developer Questions and Answers

Testing Engine

  • Product Type: Testing Engine
$42  $119.99

PDF Study Guide

  • Product Type: PDF Study Guide
$36.75  $104.99
Question 1

Given the code fragment:

What is the result?

Options:

A.

-1 : 2

B.

2 : -1

C.

2 : 3

D.

3 : 0

Question 2

Given the code fragment:

What is the result?

Options:

A.

23

B.

12

C.

123

D.

13

Question 3

Given:

Which statement is true about the Fox class?

Options:

A.

Fox class does not have to override inhabit method, so long as it does not try to call it.

B.

Fox class does not have to override the inhabit method if Forest and Town provide compatible implementations.

C.

Fox class must implement either Forest or Town interfaces, but not both.

D.

The inhabit method implementation from the first interface that Fox implements will take precedence.

E.

Fox class must provide implementation for the inhabit method.

Question 4

Given the code fragment:

You want to examine whether path is a directory.

Which code inserted on line 1 will accomplish this?

Options:

A.

BasicFileAttributes attributes = Files isDirectory (path);

B.

BasicFileAttributes attributes =Files.getAttribute (path, ‘’insdirectory’’);

C.

BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class

D.

BasicFileAttributes attributes = Files, readAttributes (path, FileAttributes, class);

Question 5

Given:

var data = new ArrayList<>();

data.add(“Peter”);

data.add(30);

data.add(“Market Road”);

data.set(1, 25);

data.remove(2);

data.set(3, 1000L);

System.out.print(data);

What is the output?

Options:

A.

[Market Road, 1000]

B.

[Peter, 30, Market Road]

C.

[Peter, 25, null, 1000]

D.

An exception is thrown at run time.

Question 6

Given:

Which is true about line 1?

Options:

A.

If the value is not present, a NoSuchElementException is thrown at run time.

B.

It always executes the System.out::print statement.

C.

If the value is not present, a NullPointerException is thrown at run time.

D.

If the value is not present, nothing is done.

Question 7

Given:

What is the result?

Options:

A.

1.99,2.99,0

B.

1.99,2.99,0.0

C.

The compilation fails.

D.

1.99,2.99

Question 8

Which method throws an exception for not-a-number and infinite input values?

A)

B)

C)

D)

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 9

Given the declaration:

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

Options:

A.

@Resource({“Customer1”, “Customer2”})

B.

@Resource(value={{}})

C.

@Resource

D.

@Resource(“Customer1”)

E.

@Resource()

Question 10

Given:

executed with this command:

java Main one two three

What is the result?

Options:

A.

0). one

B.

0). one1). two2). three

C.

The compilation fails.

D.

It creates an infinite loop printing:0). one1). two1). two...

E.

A java.lang.NullPointerException is thrown.

Question 11

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 12

Why would you choose to use a peek operation instead of a forEach operation on a Stream?

Options:

A.

to process the current item and return void

B.

to remove an item from the end of the stream

C.

to process the current item and return a stream

D.

to remove an item from the beginning of the stream

Question 13

Given:

Which statement on line 1 enables this code to compile?

Options:

A.

Function f = n −> n * 2;

B.

Function f = n −> n * 2;

C.

Function f = n −> n * 2;

D.

Function f = n −> n * 2;

E.

Function f = n −> n * 2;

Question 14

Assume ds is a DataSource and the EMP table is defined appropriately.

What does executing this code fragment do?

Options:

A.

inserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', NULL)

B.

inserts two rows (101, 'SMITH', 'HR') and (102, 'JONES', 'HR')

C.

inserts one row (101, 'SMITH', 'HR')

D.

throws a SQLException

Question 15

Given:

What must be added in line 1 to compile this class?

Options:

A.

catch(IOException e) { }

B.

catch(FileNotFoundException | IndexOutOfBoundsException e) { }

C.

catch(FileNotFoundException | IOException e) { }

D.

catch(IndexOutOfBoundsException e) { }catch(FileNotFoundException e) { }

E.

catch(FileNotFoundException e) { }catch(IndexOutOfBoundsException e) { }

Question 16

Given:

Which two lines of code when inserted in line 1 correctly modifies instance variables? (Choose two.)

Options:

A.

setCCount(c) = cCount;

B.

tCount = tCount;

C.

setGCount(g);

D.

cCount = setCCount(c);

E.

aCount = a;

Question 17

Which two expressions create a valid Java Path instance? (Choose two.)

Options:

A.

Paths.get("foo")

B.

Paths.getPath("too")

C.

Path.get(new URI("file:///domains/oracle/test.txt"))

D.

new Path("foo")

E.

Paths.get(URL.create("file:///domains/oracle/test.txt"))

Question 18

Given the code fragment:

What is the result?

Options:

A.

13 5 7 9

B.

1 3 5 7 9 11

C.

2 4 6 B 10

D.

2 4 6 8

Question 19

Which two statements set the default locale used for formatting numbers, currency, and percentages? (Choose two.)

Options:

A.

Locale.setDefault(Locale.Category.FORMAT, “zh-CN”);

B.

Locale.setDefault(Locale.Category.FORMAT, Locale.CANADA_FRENCH);

C.

Locale.setDefault(Locale.SIMPLIFIED_CHINESE);

D.

Locale.setDefault(“en_CA”);

E.

Locale.setDefault(“es”, Locale.US);

Question 20

Given the code fragment:

You want to display the value of currency as $100.00.

Which code inserted on line 1 will accomplish this?

Options:

A.

NumberFormat formatter = NumberFormat.getInstance(locale).getCurrency();

B.

NumberFormat formatter = NumberFormat.getCurrency(locale);

C.

NumberFormat formatter = NumberFormat.getInstance(locale);

D.

NumberFormat formatter = NumberFormat.getCurrencyInstance(locale);

Question 21

Given:

Which two lines inserted in line 1 will allow this code to compile? (Choose two.)

Options:

A.

protected void walk(){}

B.

void walk(){}

C.

abstract void walk();

D.

private void walk(){}

E.

public abstract void walk();

Question 22

Given:

Which three are correct? (Choose three.)

Options:

A.

b1.foo(li) prints Hello world!

B.

f1.foo(li) prints Bonjour le monde!

C.

f1.foo(li) prints Hello world!

D.

f1.foo(li) prints Hola Mundo!

E.

b1.foo(li) prints Bonjour le monde!

F.

f2.foo(li) prints Hola Mundo!

G.

f2.foo(li) prints Bonjour le monde!

Question 23

Given:

and the code fragment:

Which two Map objects group all employees with a salary greater than 30 by neighborhood? (Choose two.)

A)

B)

C)

D)

E)

Options:

A.

Option

B.

Option

C.

Option

D.

Option

Question 24

Given:

Which would cause s to be AQCD?

Options:

A.

s.replace(s.indexOf(“A”), s.indexOf(“C”), “Q”);

B.

s.replace(s.indexOf(“B”), s.indexOf(“C”), “Q”);

C.

s.replace(s.indexOf(“B”), s.indexOf(“B”), “Q”);

D.

s.replace(s.indexOf(“A”), s.indexOf(“B”), “Q”);

Question 25

You are working on a functional bug in a tool used by your development organization. In your investigation, you find that the tool is executed with a security policy file containing this grant.

What action should you take?

Options:

A.

Nothing, because it is an internal tool and not exposed to the public.

B.

Remove the grant because it is excessive.

C.

Nothing, because it is not related to the bug you are investigating.

D.

File a security bug against the tool referencing the excessive permission granted.

E.

Nothing, because listing just the required permissions would be an ongoing maintenance challenge.

Question 26

Given the code fragment:

Which two code snippets inserted independently inside println method print Mondial:domainmodel? (Choose two.)

Options:

A.

Main.prefix + Main.name

B.

prefix + getName

C.

Main.prefix + Main.getName()

D.

new Main().prefix + new Main().name

E.

prefix + name

F.

prefix + Main.name

Question 27

Which code fragment prints 100 random numbers?

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

Question 28

Given:

What is the result?

Options:

A.

A ClassCastException is thrown at runtime.

B.

AnotherClass#methodA()AnotherClass#methodA()

C.

The compilation fails.

D.

SomeClass#methodA()AnotherClass#methodA()

E.

AnotherClass#methodA()SomeClass#methodA()

F.

SomeClass#methodA()SomeClass#methodA()

Question 29

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 30

Given:

A) An exception is thrown at run time.

B)

C) The compilation fails due to an error on line 2.

D) The compilation fails due to an error on line 1.

E)

F)

The compilation fails due to an error on line 3.

Options:

A.

Option A

B.

Option B

C.

Option C

D.

Option D

E.

Option E

F.

Option F

Question 31

Given:

What is the result?

Options:

A.

Orange Juice

B.

The compilation fails.

C.

Orange Juice Apple Pie Lemmon Ice Raspberry Tart

D.

The program prints nothing.

Question 32

Given:

When is the readObject method called?

Options:

A.

before this object is deserialized

B.

after this object is deserialized

C.

before this object Is serialized

D.

The method is never called.

E.

after this object is serialized

Question 33

Given:

var fruits = List.of(“apple”, “orange”, “banana”, “lemon”);

You want to examine the first element that contains the character n. Which statement will accomplish this?

Options:

A.

String result = fruits.stream().filter(f −> f.contains(“n”)).findAny();

B.

fruits.stream().filter(f −> f.contains(“n”)).forEachOrdered(System.out::print);

C.

Optional result = fruits.stream().filter(f −> f.contains (“n”)).findFirst ();

D.

Optional result = fruits.stream().anyMatch(f −> f.contains(“n”));

Question 34

Given:

List list1 = new ArrayList<>();

list1.add(“A”);

list1.add(“B”);

List list2 = List.copyOf(list1);

list2.add(“C”);

List> list3 = List.of(list1, list2);

System.out.println(list3);

What is the result?

Options:

A.

[[A, B],[A, B]]

B.

An exception is thrown at run time.

C.

[[A, B], [A, B, C]]

D.

[[A, B, C], [A, B, C]]

Question 35

There is a copyServiceAPI that has the org.copyservice. spi. Copy interface

To use this service in a module, 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 36

Given:

What is the output?

Options:

A.

1 2 [1, 2, 3, four] 3 four

B.

1 2 [1, 2, 3, 4] 3 4

C.

1 2 [1, 2, 3, 4] 3 four

D.

1 2 [1, 2, 3, four] 3 4

Question 37

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 38

Given the code fragment:

What is the result?

Options:

A.

An ArrayIndexOutofBoundsException is thrown at runtime.

B.

The compilation fails.

C.

gh ij kl

D.

gj hk il

E.

ghi jkl

Page: 1 / 26
Total 257 questions