0% found this document useful (0 votes)
194 views176 pages

Java OCP 11 - 1Z0-819 - Dumps

Uploaded by

Saurabh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views176 pages

Java OCP 11 - 1Z0-819 - Dumps

Uploaded by

Saurabh kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 176

Questions & Answers PDF Page 1

Oracle
1Z0-819 Exam
Java SE 11 Developer

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 2

Product Questions: 214


Version: 5.0
Question: 1

Given:

What is the result?

A. nothing
B. It fails to compile.
C. 0

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 3

D. A java.lang.IllegalArgumentException is thrown.
E. 10

Answer: B

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 4

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 5

Question: 2

Given:

Which two changes need to be made to make this class compile? (Choose two.)

A. Change Line 1 to an abstract class:public abstract class API {


B. Change Line 2 access modifier to protected:protected void checkValue(Object value)throws
IllegalArgumentException;
C. Change Line 1 to a class:public class API {
D. Change Line 1 to extend java.lang.AutoCloseable:public interface API extends AutoCloseable {
E. Change Line 2 to an abstract method:public abstract void checkValue(Object value)throws
IllegalArgumentException;

Answer: C,E

Question: 3

Which two modules include APIs in the Java SE Specification? (Choose two.)

A. java.logging
B. java.desktop
C. javafx
D. jdk.httpserver E. jdk.jartool

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 6

Answer: A,D
Reference: https://docs.oracle.com/javase/9/docs/api/overview-summary.html

Question: 4

Given:

What is the output?

A. 300
B. Exception
C. 200
D. 100

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 7

Answer: A

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 8

Question: 5

Which two statements are true about the modular JDK? (Choose two.)

A. The foundational APIs of the Java SE Platform are found in the java.base module.
B. An application must be structured as modules in order to run on the modular JDK.
C. It is possible but undesirable to configure modules’ exports from the command line.
D. APIs are deprecated more aggressively because the JDK has been modularized.

Answer: A, C

Question: 6 Given the

code fragment:

What is the result?

A. -1 : 2
B. 2 : -1
C. 2 : 3
D. 3 : 0

Answer: B

Question: 7

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 9

What is the result?

A. The compilation fails.


B. abdf
C. abd
D. adf
E. abcd

Answer: E

Question: 8

Which set of commands is necessary to create and run a custom runtime image from Java source
files?

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 10

A. java, jdeps
B. javac, jlink
C. jar, jlink
D. javac, jar

Answer: B
Reference: https://blogs.oracle.com/jtc/automating-the-creation-of-jdk9-reduced-runtime-
imagesin-netbeans

Question: 9

Given:

What is the result?

A. 4
B. 3
C. An exception is thrown at runtime.
D. 5

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 11

Answer: D

Question: 10

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 12

It is required that if p instanceof Pair then p.isValid() returns true.


Which is the smallest set of visibility changes to insure this requirement is met?

A. setLeft and setRight must be protected.


B. left and right must be private.
C. isValid must be public.
D. left, right, setLeft, and setRight must be private.

Answer: B

Question: 11

Given:

What is the result?

A. 5
B. 3
C. 23
D. 25
E. 11

Answer: E

Question: 12

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 13

What is the result?

A. 2,34,34,5
B. 2,34,54,5
C. 2,54,54,5
D. 2,34,54,3

Answer: C

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 14

Question: 13

Given:

What is the result?

A. It throws a runtime exception.


B. Value of Euler = 2.71828 C. The code does not compile.
D. Value of Euler = “2.71828”

Answer: C

Question: 14

Given:

executed using this command:

java Myclass My Car is red

What is the output of this class?

A. Car--red--My
B. My--Car--is
C. My--is--java
D. java--Myclass--My
E. Myclass--Car--red
Answer: A

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 15

Question: 15

Given:

Which two allow a.Main to allocate a new Person? (Choose two.)

A. In Line 1, change the access modifier to privateprivate Person() {


B. In Line 1, change the access modifier to publicpublic Person() {
C. In Line 2, add extends Person to the Main classpublic class Main extends Person {and change Line
3 to create a new Main objectPerson person = new Main();
D. In Line 2, change the access modifier to protectedprotected class Main {
E. In Line 1, remove the access modifierPerson() {

Answer: BC

Question: 16

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 16

Which loop incurs a compile time error?

A. the loop starting line 11


B. the loop starting line 7
C. the loop starting line 14
D. the loop starting line 3

Answer: C

Question: 17

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

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.

Answer: A,C
Reference: http://tutorials.jenkov.com/java/modules.html

Question: 18

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 17

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

A. setCCount(c) = cCount;
B. tCount = tCount;
C. setGCount(g);
D. cCount = setCCount(c);
E. aCount = a;

Answer: B,E

Question: 19

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 18

What is the expected result of javac?

A. javac fails to compile the class and prints the error message, C:\workspace4\Mycar.java:1:error:
package java does not exist
B. javac compiles Mycar.java without errors or warnings.
C. javac fails to compile the class and prints the error message, C:\workspace4\Mycar.java:1:error:
expected import java.lang
D. javac fails to compile the class and prints the error message, Error: Could not find or load main
class Mycar.class

Answer: B

Question: 20

Given:

Which is true?

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.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 19

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.

Answer: A

Question: 21

Given:

Which would cause s to be AQCD?

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”);

Answer: B

Question: 22

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 20

Which two lines cause compilation errors? (Choose two.)

A. line 12
B. line 6
C. line 9
D. line 8 E. line 7

Answer: B,E

Question: 23

Which describes a characteristic of setting up the Java development environment?

A. Setting up the Java development environment requires that you also install the JRE.
B. The Java development environment is set up for all operating systems by default.
C. You set up the Java development environment for a specific operating system when you install
the JDK.
D. Setting up the Java development environment occurs when you install an IDE before the JDK.

Answer: D
Reference: https://docs.oracle.com/javame/8.1/sdk-dev-guide/install.htm

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 21

Question: 24

Given:

What is the result?


A. 42

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 22

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.

Answer: A

Question: 25

Given:

Which two statements are true if the method is added to Bar? (Choose two.)

A. public Collection<String> foo(Collection<String> arg) { ... } overrides Foo.foo.


B. public <T> Collection<T> foo(Stream<T> arg) { ... } overloads Foo.foo.
C. public <T> List<T> foo(Collection<T> arg) { ... } overrides Foo.foo.
D. public <T> Collection<T> foo(Collection<T> arg) { ... } overloads Foo.foo.
E. public <T> Collection<T> bar(Collection<T> arg) { ... } overloads Foo.foo.
F. public <T> Iterable<T> foo(Collection<T> arg) { ... } overrides Foo.foo.

Answer: C,F

Question: 26

Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 23

What is the result?

A. ab cd ef
B. An ArrayIndexOutOfBoundsException is thrown at runtime.
C. The compilation fails.
D. abc def
E. ad be cf

Answer: E

Question: 27

Given:

executed using command:

java Hello “Hello World” Hello World

What is the output?

A. An exception is thrown at runtime.


B. Hello WorldHello World
C. Hello World Hello World
D. Hello WorldHelloWorld
E. HelloHello WorldHelloWorld

Answer: C

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 24

Question: 28

Given:

Which two constructors will compile and set the class field strings? (Choose two.)

A. Option A
B. Option B
C. Option C
D. Option D
E. Option E

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 25

Answer: C,E

Question: 29

Given the code fragment:

What is the result?

A. false true true


B. true false false
C. false false true
D. false true false

Answer: D

Question: 30

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 26

What is the result?

A. watermelonorangelemongrapeapricotapple
B. nothing
C. appleapricotgrapelemonorangewatermelon
D. appleorangegrapelemonapricotwatermelon

Answer: A

Question: 31

Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 27

Which “for” loop produces the same output?

A. Option A
B. Option B
C. Option C
D. Option D

Answer: C

Question: 32

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 28

Which three classes successfully override printOne()? (Choose three.)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 29

A. Option A
B. Option B
C. Option C
D. Option D E. Option E
F. Option F

Answer: ACD

Question: 33

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 30

What is the result?

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()

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 31

Answer: C

Question: 34

Which two statements are correct about try blocks? (Choose two.)

A. A try block can have more than one catch block.


B. A finally block in a try-with-resources statement executes before the resources declared are
closed.
C. A finally block must be immediately placed after the try or catch blocks.
D. A try block must have a catch block and a finally block.
E. catch blocks must be ordered from generic to specific exception types.

Answer: A, C

Question: 35

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 32

What is the output?

A. I am an object array
B. The compilation fails due to an error in line 1.
C. I am an array
D. I am an object

Answer: D

Question: 36

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 33

What is the result?

A. The compilation fails.


B. 1.99,2.99,0
C. 1.99,2.99,0.0
D. 1.99,2.99

Answer: A

Question: 37

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 34

What is the result?

A. 2134
B. 2143
C. 214
D. 234

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 35

Answer: C

Question: 38

Given:

What is the result?

A. is it 1
B. An IndexOutOfBoundsException is thrown at runtime.
C. is it 0
D. this is it 2 E. this is it 3

Answer: D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 36

Question: 39

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

A. jmod describe
B. java Hello.java
C. jdeps --list-deps
D. jar --show-module-resolution
E. java --show-module-resolution

Answer: C,E
Reference: https://docs.oracle.com/en/java/javase/11/tools/jdeps.html#GUID-A543FEBE-
908A49BF-996C-39499367ADB4

Question: 40

Given:

What is the result?

A. [0,0] = Red[0,1] = White[1,0] = Black[1,1] = Blue[2,0] = Yellow[2,1] = Green[3,0] = Violet


B. [0,0] = Red[1,0] = Black[2,0] = Blue
C. java.lang.ArrayIndexOutOfBoundsException thrown
D. [0,0] = Red[0,1] = White[1,0] = Black[2,0] = Blue[2,1] = Yellow[2,2] = Green[2,3] = Violet

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 37

Answer: D

Question: 41

Given:

What is the result?

A. WorkingUnknown
B. Unknown
C. TuesdayUnknown

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 38

D. The compilation fails.


E. Tuesday
F. Working

Answer: B

Question: 42

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 39

Which code, when inserted at one or more marked positions, would allow classes B and C to
compile?

A. @Override // position 3void x () {} // position 3@Override // position 3public void z() { } //


position 3
B. @Override // position 2public void z() { } // position 3
C. implements A // position 1@Override // position 2
D. public void z() { } // position 3

Answer: B

Question: 43

Given:

Which is true?

A. The code compiles but does not print any result.


B. The code prints 25.
C. The code does not compile.
D. The code throws an exception at runtime.

Answer: C

Question: 44

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

A. java.base exports all of the Java platforms core packages.


B. module-info.java can be placed in any folder inside module-path.
C. A module must be declared in module-info.java file.
D. module-info.java cannot be empty.
E. By default, modules can access each other as long as they run in the same folder.
Answer: AC

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 40

Reference: http://tutorials.jenkov.com/java/modules.html

Question: 45

Which two describe reasons to modularize the JDK? (Choose two.)

A. easier to understand the Java language


B. improves security and maintainability
C. easier to expose implementation details
D. improves application robustness
E. easier to build a custom runtime linking application modules and JDK modules

Answer: B,D

Question: 46

Given:

What is the result?

A. compilation error
B. 0 5
C. 6 13

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 41

D. 5 12

Answer: A

Question: 47

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 42

Which two methods modify field values? (Choose two.)

A. setAllCounts
B. setACount
C. setGCount
D. setCCount
E. setTCount

Answer: AC

Question: 48

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 43

What is the result?

A. b1
B. 2
C. b2
D. 1
E. b3
F. 3
G. The compilation fails due to an error in line 1.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 44

Answer: F

Question: 49

Given the code fragment:

What is the result?

A. 01
B. 0
C. 1
D. The program prints nothing.
E. It prints 1 in the infinite loop.

Answer: D

Question: 50

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 45

What is the type of the local variable x?

A. Character
B. char
C. String[ ] D. String

Answer: D

Question: 51

Analyze the code:

Which two options can you insert inside println method to produce Global:namescope? (Choose
two.)

A. Test.prefix+Test.name
B. new Test().prefix+new Test().name
C. Test.prefix+Test.getName()

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 46

D. Test.getName+prefix
E. prefix+Test.name
F. prefix+name

Answer: B,C

Question: 52

Given:

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

A. public List<Integer> foo(Set<CharSequence> m) { ... }


B. public ArrayList<Number> foo(Set<CharSequence> m) { ... }
C. public List<Integer> foo(TreeSet<String> m) { ... }
D. public List<Integer> foo(Set<String> m) { ... }
E. public List<Object> foo(Set<CharSequence> m) { ... }
F. public ArrayList<Integer> foo(Set<String> m) { ... }

Answer: BC

Question: 53

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 47

What is the output?

A. Hello world!Bonjour le monde!


B. Hello world!Hello world!
C. Bonjour le monde!Hello world!
D. Bonjour le monde!Bonjour le monde!

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 48

Answer: C

Question: 54

Given:

and omitting the throws FooException clause results in a compilation error.

Which statement is true about FooException?

A. FooException is a subclass of RuntimeError.


B. FooException is unchecked.
C. The body of foo can only throw FooException.
D. The body of foo can throw FooException or one of its subclasses.

Answer: D
Reference: https://stackoverflow.com/questions/47871728/throwing-a-parent-class-exception-
forceto-throw-its-sub-class-exception-event-t

Question: 55

Which describes an aspect of Java that contributes to high performance?

A. Java prioritizes garbage collection.


B. Java has a library of built-in functions that can be used to enable pipeline burst execution.
C. Java monitors and optimizes code that is frequently executed.
D. Java automatically parallelizes code execution.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 49

Answer: C

Question: 56

Given:

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

A. Option A
B. Option B
C. Option C

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 50

D. Option D
E. Option E

Answer: A, E

Question: 57

Given the formula to calculate a monthly mortgage payment:

and these declarations:

How can you code the formula?

A. m = p * (r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1));


B. m = p * ((r * Math.pow(1 + r, n) / (Math.pow(1 + r, n)) - 1));
C. m = p * r * Math.pow(1 + r, n) / Math.pow(1 + r, n) - 1;
D. m = p * (r * Math.pow(1 + r, n) / Math.pow(1 + r, n) - 1);

Answer: A

Question: 58

Which is the correct order of possible statements in the structure of a Java class file?

A. class, package, import


B. package, import, class
C. import, package, class
D. package, class, import
E. import, class, package

Answer: B

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 51

Question: 59

Given this requirement:

Module vehicle depends on module part and makes its com.vehicle package available for all other
modules.

Which module-info.java declaration meets the requirement?

A. Option A
B. Option B
C. Option C
D. Option D

Answer: A

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 52

Question: 60

Given:

Which two statements are valid to be written in this interface? (Choose two.)

A. public abstract void methodB();


B. final void methodG(){System.out.println(“G”);}
C. private abstract void methodC();
D. public String methodD();
E. public int x;
F. final void methodE();
G. public void methodF(){System.out.println(“F”);}

Answer: AD

Question: 61

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 53

executed with this command:

java Main one two three

What is the result?

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.

Answer: D

Question: 62

Given:

Assuming that this code compiles correctly, which three statements are true? (Choose three.)

A. B cannot be abstract.
B. B is a subtype of A.
C. A cannot be abstract.
D. A cannot be final.
E. B cannot be final.
F. A is a subtype of B.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 54

Answer: ABD

Question: 63

Given:

What is known about the Sportscar class?

A. The Sportscar class is a subclass of Automobile and inherits its methods.


B. The Sportscar subclass cannot override setTurbo method from the superclass Automobile.
C. The Sportscar class is a superclass that has more functionality than the Automobile class.
D. The Sportscar class inherits the setTurbo method from the superclass Automobile.

Answer: A

Question: 64

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 55

Why does D cause a compilation error?

A. D inherits a() only from C.


B. D inherits a() from B and C but the return types are incompatible.
C. D extends more than one interface.
D. D does not define any method.

Answer: B

Question: 65

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 56

Which statement is true?

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.

Answer: A

Question: 66

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 57

What is the result?

A. null
B. nothing
C. It fails to compile.
D. java.lang.IllegalAccessException is thrown.
E. Student

Answer: C

Question: 67
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 58

What is the type of x?

A. char
B. List<Character>
C. String
D. List<String>

Answer: C

Question: 68

Which statement about access modifiers is correct?

A. An instance variable can be declared with the static modifier.


B. A local variable can be declared with the final modifier.
C. An abstract method can be declared with the private modifier.
D. An inner class cannot be declared with the public modifier.
E. An interface can be declared with the protected modifier.

Answer: B
Reference: https://javabeginnerstutorial.com/core-java-tutorial/instance-variable-java/

Question: 69

Given the code fragment:

What is the output?

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 59

A. The compilation fails.


B. [-1, -2, -3]
C. [-3, -2, -1]
D. A runtime exception is thrown.

Answer: D

Question: 70

Which command line runs the main class com.acme.Main from the module com.example?

A. java --module-path mods com.example/com.acme.Main


B. java –classpath com.example.jar com.acme.Main
C. java --module-path mods -m com.example/com.acme.Main
D. java -classpath com.example.jar –m com.example/com.acme.Main

Answer: D

Question: 71

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 60

What is the result?

A. Map: 0 Keys: 0 Values: 0


B. The compilation fails.
C. Map: 4 Keys: 4 Values: 4
D. Map: 4 Keys: 0 Values: 0
E. Map: 0 Keys: 4 Values: 4

Answer: D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 61

Question: 72

Given:

What is the result?

A. Dr. Who
B. Dr. Null
C. An exception is thrown at runtime.
D. null

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 62

Answer: D

Question: 73

Given:

What is the result?

A. 9
B. An exception is thrown at runtime.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 63

C. 3
D. 6

Answer: D

Question: 74

Given:

Which two lines can replace line 1 so that the Y class compiles? (Choose two.)

A. map.forEach((k, v) -> set(v)));


B. set(map.values());
C. super.set(List<String> map)
D. super.set(map.values());

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 64

E. set(map)

Answer: B,D

Question: 75

Given:

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

A. protected void walk(){}


B. void walk(){}
C. abstract void walk();
D. private void walk(){}
E. public abstract void walk();

Answer: A, E

Question: 76

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 65

What is the result?

A. An exception is thrown at runtime.


B. 42=(x+y)=42
C. 42=(x+y)=6
D. 6=(x+y)=42
E. 6=(x+y)=6

Answer: D

Question: 77

Given:

Which expression when added at line 1 will produce the output of 1.17?

A. float z = (float)(Math.round((float)x/y*100)/100);
B. float z = Math.round((int)(x/y),2);
C. float z = Math.round((float)x/y,2);
D. float z = Math.round((float)x/y*100)/(float)100;

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 66

Answer: D

Question: 78

Given:

executed with this command:

java Main one two three What

is the output of this class?

A. The compilation fails.


B. 1) one2) two3) three
C. A java.lang.ArrayIndexOutOfBoundsException is thrown.
D. 1) one
E. nothing
Answer: B

Question: 79

Which three initialization statements are correct? (Choose three.)

A. int x = 12_34;
B. short sh = (short)‘A’;

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 67

C. String contact# = “(+2) (999) (232)”;


D. boolean true = (4 == 4);
E. float x = 1.99;
F. int[][] e = {{1,1},{2,2}};
G. byte b = 10;char c = b;

Answer: ABF

Question: 80

Given:

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

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) { }
Answer: A

Question: 81

Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 68

What is the result?

A. 23
B. 12
C. 123
D. 13

Answer: A

Question: 82
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 69

Which three are true? (Choose three.)

A. b1.foo(c) prints Bonjour le monde!


B. f1.foo(c) prints Hello world!
C. f1.foo(c) prints Olá Mundo!
D. b1.foo(c) prints Hello world!
E. f2.foo(c) prints Olá Mundo!
F. b1.foo(c) prints Olá Mundo!
G. f2.foo(c) prints Bonjour le monde!
H. f2.foo(c) prints Hello world!
I. f1.foo(c) prints Bonjour le monde!
Answer: B,F,G

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 70

Question: 83

Given:

What is the result?

A. null
B. Joe Bloggs
C. The compilation fails due to an error in line 1.
D. p1

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 71

Answer: C

Question: 84

Given:

Which two methods facilitate valid ways to read instance fields? (Choose two.)

A. getTCount
B. getACount
C. getTotalCount

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 72

D. getCCount
E. getGCount
Answer: C,D

Question: 85

Given:

If file "App.config" is not found, what is the result?

A. Configuration is OK
B. The compilation fails.
C. Exception in thread "main" java.lang.Error:Fatal Error: Configuration File, App.config, is missing. D.
nothing

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 73

Answer: B

Question: 86

Given:

Which statement is true about the Fox class?

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 74

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.

Answer: B

Question: 87

Given:

Which three are correct? (Choose three.)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 75

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!
H. b1.foo(li) prints Hola Mundo!
I. f2.foo(li) prints Hello world!

Answer: A,B,H

Question: 88

Given:

Automobile.java

Car.java

What must you do so that the code prints 4?

A. Remove the parameter from wheels method in line 3.


B. Add @Override annotation in line 2.
C. Replace the code in line 2 with Car ob = new Car();
D. Remove abstract keyword in line 1.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 76

Answer: B

Question: 89

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?

A. java /code/a/Test.java
B. javac –d /code /code/a/Test
C. java /code/a/Test.java /code/b/Best.java

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 77

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

Answer: E

Question: 90

Examine this excerpt from the declaration of the java.se module:

What does the transitive modifier mean?

A. Only a module that requires the java.se module is permitted to require the java.sql module.
B. Any module that requires the java.se module does not need to require the java.sql module.
C. Any module that attempts to require the java.se module actually requires the java.sql module
instead.
D. Any module that requires the java.sql module does not need to require the java.se module.

Answer: A

Question: 91

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 78

What is the result?

A. JoeMarry
B. Joenull
C. nullnull
D. nullMary

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 79

Answer: D

Question: 92

Given:

What is the result?

A. Good Morning, Potter


B. Good Night, Potter
C. Good Morning, Harry
D. Good Night, Harry

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 80

Answer: B

Question: 93

Given:

What is the result?

A. NullPointerException is thrown at line 4.


B. NullPointerException is thrown at line 10.
C. A compilation error occurs.
D. Hello

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 81

Answer: D

Question: 94

Given:

What is the result?

A. nothing
B. 0
C. 10
D. 0 4 9

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 82

Answer: A

Question: 95

What makes Java dynamic?

A. At runtime, classes are loaded as needed, and new code modules can be loaded on demand.
B. The runtime can process machine language sources as well as executables from different
language compilers.
C. The Java compiler uses reflection to test if class methods are supported by resources of a target
platform.
D. The Java compiler preprocesses classes to run on specific target platforms.

Answer: A

Question: 96
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.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 83

Answer: C

Question: 97
Which two are functional interfaces? (Choose two.)

A. Option A
B. Option B C. Option C
D. Option D
E. Option E

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 84

Answer: CE
Reference: http://tutorials.jenkov.com/java-functional-programming/functional-interfaces.html

Question: 98
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

Answer: AB

Question: 99
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 85

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

A. MyInterface1
B. MyInterface3
C. MyInterface5
D. MyInterface2
E. MyInterface4

Answer: CD
Reference: https://dzone.com/articles/functional-interface-and-lambda-expression

Question: 100
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(); }

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 86

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


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

Answer: C

Question: 101
Given these two classes:

And given this fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 87

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.

Answer: D

Question: 102

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?

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 88

A. Option A
B. Option B
C. Option C
D. Option D

Answer: B

Question: 103

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 89

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.

Answer: A
Explanation:

Question: 104

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<> ();

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 90

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

Answer: B
Reference: https://docs.oracle.com/javase/8/docs/api/?java/util/ServiceLoader.html

Question: 105
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.

Answer: AC

Question: 106

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 91

What is the output?

A. null

B. A NoSuchElementException is thrown at run time.


C. Duke
D. A NullPointerException is thrown at run time.

Answer: C
Explanation:

Question: 107
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 92

What is the result?

A. The compilation fails at line 9.


B. The compilation fails at line 2.
C. Hello World
D. The compilation fails at line 8.

Answer: C
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 93

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

What does executing this code fragment do?

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

Answer: C

Question: 109
Assuming the Widget class has a getPrice method, this code does not compile:

Which two statements, independently, would allow this code to compile? (Choose two.)

A. Replace line 5 with widgetStream.filter(a −> ((Widget)a).getPrice() > 20.00).


B. Replace line 1 with List<Widget> widgetStream = widgets.stream();.
C. Replace line 5 with widgetStream.filter((Widget a) −> a.getPrice() > 20.00).
D. Replace line 4 with Stream<Widget> widgetStream = widgets.stream();.

Answer: AD

Question: 110

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 94

Which statement on line 1 enables this code to compile?

A. Function<Integer, Integer> f = n −> n * 2;


B. Function<Integer> f = n −> n * 2;
C. Function<int> f = n −> n * 2;
D. Function<int, int> f = n −> n * 2;
E. Function f = n −> n * 2;

Answer: A

Explanation:

Question: 111
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?

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 95

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<String> result = fruits.stream().filter(f −> f.contains (“n”)).findFirst ();
D. Optional<String> result = fruits.stream().anyMatch(f −> f.contains(“n”));

Answer: B
Explanation:

Question: 112
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 96

What is required to make the Foo class thread safe?

A. No change is required.
B. Make the declaration of lock static.
C. Replace the lock constructor call with new ReentrantLock (true).

D. Move the declaration of lock inside the foo method.

Answer: C
Reference: https://stackoverflow.com/

Question:s/55134811
/how-to-make-java-class-thread-safe

Question: 113
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?

A. [Market Road, 1000]


B. [Peter, 30, Market Road]

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 97

C. [Peter, 25, null, 1000]


D. An exception is thrown at run time.
Answer: D
Explanation:

Question: 114
Which code fragment compiles?

A. Option A
B. Option B
C. Option C
D. Option D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 98

Answer: D

Explanation:

Question: 115
Which two are successful examples of autoboxing? (Choose two.)

A. String a = “A”;
B. Integer e = 5;
C. Float g = Float.valueOf(null);
D. Double d = 4;
E. Long c = 23L;
F. Float f = 6.0;

Answer: AB

Question: 116
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 99

What code must you insert on Line 1 to enable the code to print Hello world?
A. Hello.Greeting myG = new Hello.Greeting() myG.sayHi();
B. Hello myH = new Hello();
Hello.Greeting myG = myH.new Greeting();
myG.sayHi();
C. Hello myH = new Hello();
Hello.Greeting myG = myH.new Hello.Greeting();
myG.sayHi();
D. Hello myH = new Hello(); Greeting myG = new Greeting(); myG.sayHi ();

Answer: B
Explanation:

Question: 117
Which code fragment prints 100 random numbers?

A. Option A
B. Option B
C. Option C
D. Option D

Answer: D
Reference: https://www.javacodegeeks.com/2014/01/java-util-random-in-java-8.html

Question: 118
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.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 100

What action should you take?

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.

Answer: D
Reference: https://wiki.sei.cmu.edu/confluence/display/java/ENV03-
J.+Do+not+grant+dangerous+combinations+of+permissions

Question: 119
Given an application with a main module that has this module-info.java file:

Which two are true? (Choose two.)

A. A module providing an implementation of country.CountryDetails can be compiled and added


without recompiling the main module.
B. A module providing an implementation of country.CountryDetails must have a requires main;
directive in its module-info.java file.
C. An implementation of country.countryDetails can be added to the main module.
D. To compile without an error, the application must have at least one module in the module source
path that provides an implementation of country.CountryDetails.
E. To run without an error, the application must have at least one module in the module path that
provides an implementation of country.CountryDetails.

Answer: BD
Reference: https://stackoverflow.com/

Question:s/49476559
/java-9-error-not-in-a-module-on-the-module-source- path

Question: 120
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 101

What action ensures successful compilation?

A. Replace public Color(int c) with private Color(int c).


B. Replace int c; with private int c;.
C. Replace int c; with private final int c;.
D. Replace enum Color implements Serializable with public enum Color.
E. Replace enum Color with public enum Color.

Answer: A
Explanation:

Question: 121

var numbers = List.of(0,1,2,3,4,5,6,7,8,9);

You want to calculate the average of numbers. Which two codes will accomplish this? (Choose two.)

A. double avg = numbers.stream().parallel().averagingDouble(a −> a);


B. double avg = numbers.parallelStream().mapToInt (m −> m).average().getAsDouble ();
C. double avg = numbers.stream().mapToInt (i −> i).average().parallel();
D. double avg = numbers.stream().average().getAsDouble();
E. double avg = numbers.stream().collect(Collectors.averagingDouble(n −> n));

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 102

Answer: BD

Explanation:

Question: 122
Given:

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

A. Function function = String::toUpperCase;


B. UnaryOperator function = s −> s.toUpperCase();
C. UnaryOperator<String> function = String::toUpperCase;
D. Function<String> function = m −> m.toUpperCase();

Answer: C
Explanation:

Question: 123
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 103

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

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<String> lines = Files.lines(INPUT_FILE_NAME);

Answer: C

Question: 124

Given:

Which is true?

A. System.out is the standard output stream. The stream is open only when System.out is called.
B. System.in cannot reassign the other stream.
C. System.out is an instance of java.io.OutputStream by default.
D. System.in is the standard input stream. The stream is already open.

Answer: D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 104

Reference: https://www.geeksforgeeks.org/java-lang-system-class-java/

Question: 125
Given:

and

Which code fragment on line 1 makes the s1 set contain the names of all employees born before
January 1, 1989?

A. Option A
B. Option B
C. Option C
D. Option D

Answer: B

Question: 126
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 105

Which statement is equivalent to line 1?

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);
Answer: C
Explanation:

Question: 127
Which interface in the java.util.function package will return a void return type?

A. Supplier
B. Predicate
C. Function

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 106

D. Consumer

Answer: D
Reference: https://www.geeksforgeeks.org/java-8-consumer-interface-in-java-with-examples/

Question: 128
Given:

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

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.

Answer: D
Reference: https://stackabuse.com/the-try-with-resources-statement-in-java/

Question: 129
Given:

Which two are correct? (Choose two.)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 107

A. Option A
B. Option B
C. Option C
D. Option D

Answer: CD

Question: 130

Given:

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

A. The compilation fails.


B. /u01/work/filestore.txt is not deleted.
C. Exception

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 108

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

Answer: A
Explanation:

Question: 131
Given:

You want the code to produce this output:


John

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 109

Joe
Jane

Which code fragment should be inserted on line 1 and line 2 to produce the output?

A. Insert Comparator<Person> on line 1.


Insert
public int compare(Person p1, Person p2) {
return p1.name.compare(p2.name);
}
on line 2.

B. Insert Comparator<Person> on line 1.


Insert
public int compareTo(Person person) {
return person.name.compareTo(this.name);
}
on line 2.

C. Insert Comparable<Person> on line 1.


Insert
public int compare(Person p1, Person p2) {
return p1.name.compare(p2.name);
}
on line 2.

D. Insert Comparator<Person> on line 1.


Insert
public int compare(Person person) {
return person.name.compare(this.name);
}
on line 2.

Answer: B
Reference: https://www.coursehero.com/file/p320ss6/Override-public-int-compareTo-Person-
other-
Compare- this-objects-name-to-others/

Question: 132
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 110

and

What is the result?

A. A NullPointerException is thrown at run time.


B. The compilation fails.
C. 1
Null
null
D. 1
1
1
E. A ClassCastException is thrown at run time.

Answer: B
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 111

Question: 133

Which statement about a functional interface is true?

A. It must be defined with the public access modifier.


B. It must be annotated with @FunctionalInterface.
C. It is declared with a single abstract method.
D. It is declared with a single default method.
E. It cannot have any private methods and static methods.

Answer: C
Reference: https://www.geeksforgeeks.org/functional-interfaces-java/

Question: 134

Given:

And the command:

java Main Helloworld

What is the result ?

A. Input: Echo:
B. Input: Helloworld Echo: Helloworld
C. Input:
Then block until any input comes from System.in.
D. Input:
Echo: Helloworld
E. A NullPointerException is thrown at run time.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 112

Answer: C
Explanation:

Question: 135

Given:

public class X {
}

and

public final class Y extends X {


}

What is the result of compiling these two classes?

A. The compilation fails because there is no zero args constructor defined in class X.
B. The compilation fails because either class X or class Y needs to implement the toString() method.
C. The compilation fails because a final class cannot extend another class.
D. The compilation succeeds.

Answer: B
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 113

Question: 136

Which code is correct?

A. Runnable r = “Message” −> System.out.println();


B. Runnable r = () −> System.out::print;
C. Runnable r = () -> {System.out.println(“Message”);};
D. Runnable r = −> System.out.println(“Message”);
E. Runnable r = {System.out.println(“Message”)};

Answer: C
Reference: https://www.oracle.com/technical-resources/articles/java/architect-lambdas-part1.html

Question: 137
Given:

What is the output?

A. :APPLE:ORANGE:BANANA
appleorangebanana B.
:APPLE:ORANGE:BANANA
C. APPLE:apple ORANGE:orange BANANA:banana
D. appleorangebanana
:APPLE:ORANGE:BANANA
E. apple:APPLE orange:ORANGE banana:BANANA

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 114

Answer: E

Explanation:

Question: 138
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 115

Which option should you choose to enable the code to print Something happened?

A. Add extends GeneralException on


line 1. Add extends Exception on line 2.
B. Add extends SpecificException on
line 1. Add extends GeneralException on line
2. C. Add extends Exception on line 1. Add
extends Exception on line 2.
D. Add extends Exception on line 1.
Add extends GeneralException on line 2.

Answer: D
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 116

Question: 139
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 117

What will secure this code from a potential Denial of Service condition?

A. After Line 4, add indexReader.close().


B. On Line 3, enclose processData(dataReader) with try with resources.
C. After Line 3, add dataReader.close().
D. On Line 1, use try with resources when opening each dataReader.
E. Before Line 1, check the size of dataFiles to make sure it does not exceed a threshold.

Answer: B

Question: 140
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;

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 118

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)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 119

A. Option A
B. Option B
C. Option C
D. Option D

Answer: C
Reference: https://developer.ibm.com/tutorials/java-modularity-3/

Question: 141
Given:

String originalPath = “data\\projects\\a-project\\..\\..\\another-project”;


Path path = Paths.get(originalPath);
System.out.print(path.normalize());

What is the result?

A. data\another-project
B. data\projects\a-project\another-project
C. data\\projects\\a-project\\..\\..\\another-project
D. data\projects\a-project\..\..\another-project

Answer: D
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 120

Question: 142
Given:

This code results in a compilation error.

Which code should be inserted on line 1 for a successful compilation?

A. Consumer consumer = msg -> { return System.out.print(msg); };


B. Consumer consumer = var arg −> {System.out.print(arg);};
C. Consumer consumer = (String args) −> System.out.print(args);
D. Consumer consumer = System.out::print;

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 121

Answer: D
Explanation:

Question: 143
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 122

What is the result?

A. 6910 3
B. 10126 3
C. 3
D. 6104 3

Answer: D
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 123

Question: 144
Which is a proper JDBC URL?

A. jdbe.mysql.com://localhost:3306/database

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 124

B. http://localhost.mysql.com:3306/database
C. http://localhost mysql.jdbc:3306/database
D. jdbc:mysql://localhost:3306/database

Answer: D
Reference: https://vladmihalcea.com/jdbc-driver-connection-url-strings/

Question: 145
Given:

When is the readObject method called?

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

Answer: B
Reference: https://www.oracle.com/technical-resources/articles/java/javaserial.html

Question: 146
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 125

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

A. after line 8
B. after line 6
C. after line 5
D. after line 10

Answer: B
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 126

Question: 147
Given:

List<String> list1 = new


ArrayList<>(); list1.add(“A”);
list1.add(“B”); List list2 =
List.copyOf(list1); list2.add(“C”);
List<List<String>> list3 = List.of(list1,
list2); System.out.println(list3); What is
the result?

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


B. An exception is thrown at run time.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 127

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


D. [[A, B, C], [A, B, C]]

Answer: B
Explanation:

Question: 148
Given:

Which three actions implement Java SE security guidelines? (Choose three.)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 128

A. Change line 7 to return names.clone();.


B. Change line 4 to this.names = names.clone();.
C. Change the getNames() method name to get$Names().
D. Change line 6 to public synchronized String[] getNames() {.
E. Change line 2 to private final String[] names;.
F. Change line 3 to private Secret(String[] names) {.
G. Change line 2 to protected volatile String[] names;.

Answer: EFG
Question: 149
Given:

Which two are correct? (Choose two.)

A. The output will be exactly 2 1 3 4 5.


B. The program prints 1 4 2 3, but the order is unpredictable.
C. Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5, but the order is
unpredictable.
D. Replacing forEach() with forEachOrdered(), the program prints 1 2 3 4 5.
E. Replacing forEach() with forEachOrdered(), the program prints 2 1 3 4 5.

Answer: BD
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 129

Question: 150
Given the contents:

MessageBundle.properties file:
message=Hello

MessageBundle_en.properties file:
message=Hello (en)

MessageBundle_US.properties file:
message=Hello (US)

MessageBundle_en_US.properties file:
message=Hello (en_US)

MessageBundle_fr_FR.properties file:
message=Bonjour

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 130

and the code fragment:

Locale.setDefault(Locale.FRANCE);
Locale currentLocale = new Locale.Builder().setLanguage(“en”).build();

ResourceBundle messages = ResourceBundle.getBundle(“MessageBundle”, currentLocale);


System.out. println(messages.getString(“message”));

Which file will display the content on executing the code fragment?

A. MessageBundle_en_US.properties
B. MessageBundle_en.properties
C. MessageBundle_fr_FR.properties
D. MessageBundle_US.properties
E. MessageBundle.properties

Answer: C
Reference: https://www.javatpoint.com/ResourceBundle-class
Question: 151
Given:

Which is true about line 1?

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.

Answer: D
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 131

Question: 152
Given:

What is the result?

A. 3533
B. 3333
C. 3535
D. 5533

Answer: A
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 132

Question: 153
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 133

Which two independent changes will make the Main class compile? (Choose two.)

A. Move the entire Student class declaration to a separate Java file, Student.java.
B. Change line 2 to public Student(String classname).
C. Change line 1 to public class Student {.
D. Change line 3 to Student student = new Student(“Biology”);.
E. Change line 1 to static class Student {.

Answer: BD
Explanation:

Question: 154
Given:

and:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 134

Which code, when inserted on line 10, prints the number of unique localities from the roster list?

A. .map(Employee::getLocality)
.distinct()
.count();
B. map(e −> e.getLocality())
.count();
C. .map(e −> e.getLocality())
.collect(Collectors.toSet())
.count();
D. .filter(Employee::getLocality)
.distinct()
.count();

Answer: D
Reference: https://developer.android.com/reference/android/location/Address

Question: 155
Given the Person class with age and name along with getter and setter methods, and this code
fragment:

What will be the result?

A. Aman Tom Peter


B. Tom Aman Peter
C. Aman Peter Tom
D. Tom Peter Aman

Answer: C

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 135

Question: 156
Which three guidelines are used to protect confidential information? (Choose three.)

A. Limit access to objects holding confidential information.


B. Clearly identify and label confidential information.
C. Manage confidential and other information uniformly.
D. Transparently handle information to improve diagnostics.
E. Treat user input as normal information.
F. Validate input before storing confidential information.
G. Encapsulate confidential information.

Answer: ADF

Reference: https://danielkvist.net/code/java-secure-coding-guidelines

Question: 157
Given:

When run and all three files exist, what is the state of each reader on Line 1?

A. All three readers are still open.


B. All three readers have been closed.
C. The compilation fails.
D. Only reader1 has been closed.

Answer: C

Question: 158
Given the code fragment:

var pool = Executors.newFixedThreadPool(5);


Future outcome = pool.submit(() −> 1);

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 136

Which type of lambda expression is passed into submit()?

A. java.lang.Runnable
B. java.util.function.Predicate
C. java.util.function.Function

D. java.util.concurrent.Callable

Answer: D
Reference:
https://www.codota.com/code/java/methods/java.util.concurrent.Executors/newFixedThreadPool

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

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);

Answer: BD
Reference: https://www.oracle.com/technical-resources/articles/javase/locale.html

Question: 160
Given:

Which two are secure serialization of these objects? (Choose two.)

A. Define the serialPersistentFields array field.


B. Declare fields transient.
C. Implement only readResolve to replace the instance with a serial proxy and not writeReplace.
D. Make the class abstract.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 137

E. Implement only writeReplace to replace the instance with a serial proxy and not readResolve.

Answer: AC

Question: 161
A bookstore's sales are represented by a list of Sale objects populated with the name of the
customer and the books they purchased.

public class Sale { private


String customer; private
List<Book> items;
// constructor, setters and getters not shown
}
public class Book {
private String name;
private double price;
// constructor, setters and getters not shown
}

Given a list of Sale objects, tList, which code fragment creates a list of total sales for each customer
in ascending order?

A. Option A
B. Option B
C. Option C
D. Option D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 138

Answer: C

Question: 162
Which two safely validate inputs? (Choose two.)

A. Delegate numeric range checking of values to the database.


B. Accept only valid characters and input values.
C. Use trusted domain-specific libraries to validate inputs.
D. Assume inputs have already been validated.
E. Modify the input values, as needed, to pass validation.

Answer: AB
Reference: https://stackoverflow.com/
Question:s/3059333
/validating-input-using-java-util-scanner

Question: 163
Consider this method declaration:

A) “SET SESSION AUTHORIZATION “ + user


B) “SET SESSION AUTHORIZATION “ + stmt.enquoteIdentifier(user)

Is A or B the correct replacement for <EXPRESSION> and why?

A. A, because it sends exactly the value of user provided by the calling code.
B. B, because enquoting values provided by the calling code prevents SQL injection.
C. A and B are functionally equivalent.
D. A, because it is unnecessary to enclose identifiers in quotes.
E. B, because all values provided by the calling code should be enquoted.

Answer: A
Reference:
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&ved=2ahUKEwj7ycO80fLo
AhVHPcAKHcoLC9cQFjADegQIAxAB&
url=ftp%3A%2F%2Fftp.software.ibm.com%2Fps%2Fproducts%2Fdb2%2Finfo%2Fvr9%2Fpdf%2Fletter
% 2Fen_US%2Fdb2s2e90.pdf&usg=AOvVaw2VqpeEh5HpbeXfa0OB5Lec

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 139

Question: 164
Which three annotation uses are valid? (Choose three.)

A. Function<String, String> func = (@NonNull x) −> x.toUpperCase();


B. var v = “Hello” + (@Interned) “World”
C. Function<String, String> func = (var @NonNull x) −> x.toUpperCase();
D. Function<String, String> func = (@NonNull var x) −> x.toUpperCase();
E. var myString = (@NonNull String) str;
F. var obj = new @Interned MyObject();

Answer: ACF

Question: 165
Which two statements correctly describe capabilities of interfaces and abstract classes? (Choose
two.)

A. Interfaces cannot have protected methods but abstract classes can.


B. Both interfaces and abstract classes can have final methods.
C. Interfaces cannot have instance fields but abstract classes can.
D. Interfaces cannot have static methods but abstract classes can.
E. Interfaces cannot have methods with bodies but abstract classes can.

Answer: AC
Reference: https://www.guru99.com/interface-vs-abstract-class-java.html

Question: 166
Given:

What is the result?

A. Orange Juice
B. The compilation fails.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 140

C. Orange Juice Apple Pie Lemmon Ice Raspberry Tart


D. The program prints nothing.

Answer: C

Explanation:

Question: 167
Which interface in the java.util.function package can return a primitive type?

A. ToDoubleFunction
B. Supplier
C. BiFunction
D. LongConsumer

Answer: A
Reference: http://java.boot.by/ocpjp8-upgrade-guide/ch02s07.html

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 141

Question: 168
Given:

and

checkQuality(QUALITY.A);

and

Which code fragment can be inserted into the switch statement to print Best?

A. QUALITY.A.ValueOf()
B. A
C. A.toString()
D. QUALITY.A

Answer: B

Question: 169

Given:

LocalDate d1 = LocalDate.of(1997,2,7);
DateTimeFormatter dtf =
DateTimeFormatter.ofPattern( /*insert code here*/ );
System.out.println(dtf.format (d1));

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 142

Which pattern formats the date as Friday 7th of February 1997?

A. “eeee dd+”th of”+ MMM yyyy”


B. “eeee dd'th of' MMM yyyy”
C. “eeee d+”th of”+ MMMM yyyy”
D. “eeee d’th of’ MMMM yyyy”

Answer: B

Question: 170
Which two statements independently compile? (Choose two.)

A. List<? super Short> list = new ArrayList<Number>();


B. List<? super Number> list = new ArrayList<Integer>();
C. List<? extends Number> list = new ArrayList<Byte>();
D. List<? extends Number> list = new ArrayList<Object>();
E. List<? super Float> list = new ArrayList<Double>();

Answer: AC
Explanation:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 143

Question: 171
Given this enum declaration:

Examine this code:

System.out.println(Letter.values()[1]);

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 144

What code should be written at line 5 for this code to print 200?

A. public String toString() { return String.valueOf(ALPHA.v); }


B. public String toString() { return String.valueOf(Letter.values()[1]); }
C. public String toString() { return String.valueOf(v); }
D. String toString() { return “200”; }

Answer: C
Explanation:

Question: 172
Given the code fragment:

Path source = Paths.get(“/repo/a/a.txt”);


Path destination = Paths.get(“/repo”);
Files.move(source, destination); // line 1 Files.delete
(source); // line 2

Assuming the source file and destination folder exist, what Is the result?

A. A java.nio.file.FileAlreadyExistsException is thrown on line 1.


B. A java.nio.file.NoSuchFileException is thrown on line 2.
C. A copy of /repo/a/a.txt is moved to the /repo directory and /repo/a/a.txt is deleted.
D. a.txt is renamed repo.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 145

Answer: C

Question: 173

Given:

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


List<String> shortlist = new ArrayList<>();

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

A. Option A
B. Option B
C. Option C
D. Option D

Answer: C

Question: 174

Given: jdeps -jdkinternals

C:\workspace4\SimpleSecurity\jar\classes.jar

Which describes the expected output?

A. jdeps lists the module dependencies and the package names of all referenced JDK internal APIs. If
any are found, the suggested replacements are output in the console.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 146

B. jdeps outputs an error message that the -jdkinternals option requires either the -summary or the
verbose options to output to the console.
C. The -jdkinternals option analyzes all classes in the .jar and prints all class-level dependencies.
D. The -jdkinternals option analyzes all classes in the .jar for class-level dependencies on JDK internal
APIs. If any are found, the results with suggested replacements are output in the console.

Answer: A
Explanation:
-jdkinternals option analyzes all classes in the .jar for class-level dependencies on JDK internal APIs. If
any are found, the results with suggested replacements are output in the console.

Question: 175
Given:

Which annotation should be used to remove warnings from compilation?

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

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 147

Answer: B
Explanation:

Question: 176
Given:

Which code fragment on line 1 makes the m map contain the employee with the highest salary for
each neighborhood?
A)

B)

C)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 148

D)

A. Option A
B. Option B
C. Option C
D. Option D

Answer: D

Question: 177
Given TripleThis.java:

Compiling TripleThis.java gives this compiler warning:


Note: TripleThis.java uses unchecked or unsafe operations.
Which two replacements done together remove this compiler warning?

A. Replace line 9 with function<Integer> tripler = x-> - { return (Integer) X * 3 ; }.


B. Replace line 12 with public static void printValue function<Integer> f, int num) {.
C. Replace line 12 with public static int printValue function<Integer, Integer>, f, T num {.
D. Replace line 12 with public static <T> void printValue (Function<T, T> f, T num ) {, E. Replace line 9

with function<Integer>, Integer> = X -> { return (integer) x * 3; }. Answer: AC

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 149

Question: 178
Given the content:

What Is the result?


A)

B)

C)

D)

E)
User Username

A. Option A
B. Option B
C. Option C
D. Option D
E. Option

Answer: DE

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 150

Question: 179
Given the code fragment:

What is the result?

A. A java.lang, UnsupportedOperationException is thrown.


B. True
C. False
D. A java.lang.NullPointerException is thrown.

Answer: A
Question: 180
Given:

What is the result?

A. The compilation fails.


B. Y@<< hashcode>>

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 151

C. Null
D. HH
Answer: B

Question: 181

A)

B)

C)

D)

A. Option A
B. Option B
C. Option C
D. Option D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 152

Answer: D
Question: 182
Given the code fragment:

What is the result?

A. 1
B. The compilation fails at line
C. 10
D. The compilation fails at line 16.
E. The compilation fails at line 13.

Answer: C

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 153

Question: 183

What change will cause the code to compile successfully?

A. Insert PriceChecker (?) prod on line 1.


B. Insert PriceChecker <> prod on line 1.
C. Insert PriceChecker <Electronics> prod on line 1.
D. Insert PriceChecker <Plushy extends Products> prod on line 1.

Answer: A

Question: 184

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 154

You want to obtain the Filechannel object on line 1.


Which code fragment will accomplish this?
A)

B)

C)

D)

A. Option A
B. Option B
C. Option C
D. Option D

Answer: A

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 155

Question: 185

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 156

Why does this compilation fail?

A. The method Y. print (object) does not call the method super.print (object)
B. The method x. print (object) is not accessible to Y.
C. In method x. print (Collection), system. Out :: prints is an invalid Java identifier.
D. The method print (object) and the method print (object…) are duplicates of each other.
E. The method Y. print (object…) cannot override the final method x.print (object….).

Answer: D

Question: 186
Which method throws an exception for not-a-number and infinite input values?
A)

B)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 157

C)

D)

A. Option A
B. Option B
C. Option C
D. Option D

Answer: A

Question: 187
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)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 158

A. Option A
B. Option B
C. Option C
D. Option D

Answer: C

Question: 188
Given:

You wants to make the reduction operation parallelized.


Which two modifications will accomplish this?

A. Replace line 1 with int sum = numbers. Stream (). Interate (0, a -> a+1. Reduce (0, (n m) -> n+m);
B. Replace line 1with int sum = numbers. ParallelStream ( ). Reduce (0, (n, m ) -> n + m);
C. Replace line 1 with int sum = numbers. Parallel ( ). Stream ( ). Reduce (0, (n, m ) -> n + m);
D. Replace line 1with int sum = number. Stream ( ) . flatMap (a -> a) .reduce (0, (n, m) -> n +m ); E.
Replace line 1with int sum = number.stream. parallel ( ). Reduce (0, (n, m) -> n + m);

Answer: AD
Question: 189
Given:

What is the result?

A. An indexOutofBoundsException is thrown at runtime.


B. At once 0
C. Hat at store 4
D. At once 1
E. Hat at store 1

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 159

Answer: E

Question: 190
Given:

What is the result?


A)

B)

C)

D)

A. Option A
B. Option B
C. Option C
D. Option D

Answer: A

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 160

Question: 191
Given the code fragment:

What is the result?

A. 13 5 7 9
B. 1 3 5 7 9 11
C. 2 4 6 B 10
D. 2 4 6 8

Answer: B

Question: 192
A company has an existing Java app that includes two Java 8 jar files, sales-3.10. jar and clients-
10.2.jar.
The jar file ,sales -8, 10, jar reference packages in clients -10.2 jar, but clients-10.2 jar does not
reference packages in sales -8.10, jar.
They have decided to modularize clients-10.2.jar.
Which module-info. Java file would work for the new library version clients-10.3 jar?
A)

B)

C)

D)

A. Option A
B. Option B
C. Option C
D. Option D

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 161

Answer: C

Question: 193

How many Thing objects are eligible for garbage collection in line 1?

A. 3
B. 2
C. 0
D. 1
E. 4

Answer: D

Question: 194
Given the Customer table structure:
• ID Number Primary Key
• NAME Text Nullable
Given code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 162

Which statement inserted on line 14 sets NAME column to a NULL value?

A. Stmt.setNull(2, java,sql. Types, VARCHAR);


B. Stmt.setNull(2 string, class);
C. Stmt.setNull(2, null);
D. Stmt.setNull(2, java.lang, string);

Answer: A
Question: 195
Given:

You want to implement the jav


a. Io, serializable interface to the MypersisteneData class.
Which method should be overriden?
A. The readExternal and writeExternal method
B. The readExternal method
C. The writeExternal method
D. nothing

Answer: A

Question: 196

Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 163

What is the result?

A. 2134
B. 234
C. 2341
D. 214

Answer: A

Question: 197
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 164

You want to examine the items list it contains an item for which the variable count is below zero.
Which code fragment at line 1 accomplish this?
A. If (items.stream () .filter (i -> count < 0) . findFirst () ) {
B. If (items.stream () .filter (i -> count < 0) . findAny () ) {
C. If (items.stream () .allmatch (i -> count < 0) < 0) ) {
D. If (items.stream () .anymatch (i -> count < 0) < 0) ) {

Answer: A
Question: 198
Given:

What is the result?

A. Take extra care


B. The program prints nothing.
C. Take extra care
Take extra care
D. An exception is thrown at runtime

Answer: D

Question: 199
Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 165

What is the result?

A. 2
B. -1
C. 1
D. -3

Answer: A

Question: 200
Given the code fragment:

What is the result?


A)

B)

C)

D)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 166

A. Option A
B. Option B
C. Option C
D. Option D

Answer: C
Question: 201
Given:

What is the result?

A. Keys: 4 Values: 4 Map: 0


B. Keys: 4 Values: 4 Map: 4
C. The compilation fails.
D. Keys: 0 Values: 0 Map:
E. Keys: 0 Values: 0 Map: 0

Answer: B

Question: 202
Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 167

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

A. i—;
B. continue b;
C. break b;
D. j--;
E. continue a;
F. break a ;

Answer: F

Question: 203
Given:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 168

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.

A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F

Answer: A
Question: 204
Given:

Which three classes successfully override showFirst ()?


A)

B)

C)

D)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 169

E)

F)

A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
F. Option F

Answer: C
Question: 205

And the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 170

Which situation will occur on code fragment execution?

A. Livelock
B. Deadlock
C. Race Condition
D. Starvation

Answer: D
Question: 206
Given the code fragment:

What is the result?

A. An ArrayIndexOutofBoundsException is thrown at runtime.


B. The compilation fails.
C. gh ij kl
D. gj hk il E. ghi jkl

Answer: A

Question: 207
Given the code fragment:

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 171

What change on line 1 will make this code compile?

A. Add catch (L |N e).


B. Add catch (L |M N e).
C. Add catch (L e).
D. Add catch (N | L | M e).
E. Add catch (M |L e).

Answer: C
Question: 208
Given the code fragment:

You want to examine whether path is a directory.


Which code inserted on line 1 will accomplish this?

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);

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 172

Answer: D

Question: 209
Given the code fragment:

Which can replace line 11?

A. UnaryOperator<Interger > uo = (var x ) -> (x * 3);


B. UnaryOperator<Interger >uo = var x -> { return x 3 ; };
C. UnaryOperator<Interger >uo = x -> { return x * 3; };
D. UnaryOperator<Interger >uo = (int x) -> x * 3;

Answer: A

Question:115
Given
:

What is the correct definition of the JsonField annotation that makes the Point class compile?
A)

B)

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 173

C)

A. Option A
B. Option B
C. Option C

Answer: A

Question: 210
Your organization makes mlib.jar available to your cloud customers. While working on a code
cleanup project for mlib.jar, you see this method by customers:

What security measures should be added to this method so that it meets the requirements for a
customer accessible method? A.

B. Create a method that validates the hostName and portNumber parameters before opening the
socket.
C. Make enableService private.
D. Enclose the call to new Socket In an AccessController.doPrivileged block.
Answer: D

Question: 211
Given the code fragment:
Which two code snippets inserted independently inside print method print Mondial: domainmodal?

A. prefix + name

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 174

B. prefix + getName
C. new Main (} .prefix + new Main().name
D. prefix + Main, name
E. Main.prefix + Main.name
F. Main.prefix + Main.getName()

Answer: CD

Question: 212
Given:

What is the output?

A. A compilation error is thrown.


B. Message from Copier: Attempt00 C. Message from Abstract
Copier: Attempt00
D. A runtime error is thrown.

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 175

Answer: A
Question: 213
Given:

Which two codes, independently, can be inserted in line to 1 compile?

A. Abacus aba = (int m, int n) -> { m * n };


B. Abacus aba = (int e, int f) -> { return e * f; };
C. Abacus aba = (a, b) -> a * b;
D. Abacus aba = v, w -> x * y;
E. Abacus aba = (int i, j) -> ( return i * j; };

Answer: CE
Question: 214
Given the code fragment:

Which code fragment replaces the for statement?

A. IntStream.rangeClosed(l, 100).map(FizzBuzz::convert).forEach(System.out::println);
B. IntStream.ranged, 100).map(FizzBuzz::convert).forEach(System.out::println);
C. intstream.rangeclosed(l, 100).mapToObj{FizzBuzz::convert).forEach(System.out::printIn); D.
IntStream.range(1, 100).mapToObj(FizzBuzz::convert).forEach(System.out::println);

https://www.examdumps.co/1z0-819-exam-dumps.html
Questions & Answers PDF Page 176

Answer: A

Thank You for Purchasing 1Z0-819 PDF

https://www.examdumps.co/1z0-819-exam-dumps.html

You might also like