ORACLE
(1Z0-819)
JAVA SE 11 DEVELOPER :1Z0-819
Visit us- [Link]
Like & Subscribe Us: [Link]
Questions: 1 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given:
executed using command:
java Hello ''Hello World'' Hello World
What is the output?
Options
A An exception is thrown at runtime.
B Hello WorldHello World
C Hello World Hello World
D Hello WorldHelloWorld
E HelloHello WorldHelloWorld
Answer C
Questions: 2 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given the code fragment:
Which ''for'' loop produces the same output?
Options
A Option A
B Option B
C Option C
D Option D
Answer C
Questions: 3 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given:
var fruits = [Link](''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 = [Link]().filter(f > [Link](''n'')).findAny();
B [Link]().filter(f > [Link](''n'')).forEachOrdered([Link]::print);
C Optional<String> result = [Link]().filter(f > [Link] (''n'')).findFirst ();
D Optional<String> result = [Link]().anyMatch(f > [Link](''n''));
Answer B
Questions: 4 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given:
String originalPath = ''data\\projects\\a-project\\..\\..\\another-project'';
Path path = [Link](originalPath);
[Link]([Link]());
What is the result?
Options
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
Questions: 5 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given:
List longlist = [Link](''Hello'',''World'',''Beat'');
List shortlist = new ArrayList<>();
Which code fragment correctly forms a short list of words containing the letter ''e''?
Options
A Option A
B Option B
C Option C
D Option D
Answer C
Questions: 6 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
MultipleChoice
Given:
jdeps -jdkinternals C:\workspace4\SimpleSecurity\jar\[Link]
Which describes the expected output?
Options
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.
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.
Questions: 7 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
To which of the following attacks is this code vulnerable?
public boolean getEmployee(Integer id) throws SQLException
{
var sql = “SELECT * FROM emp WHERE id = ?”;
try (var stmt = [Link](sql))
{
[Link](1, id);
try (var rs = [Link](sql))
{
return [Link]();
}
}
}
A. Leaking Resources
B. Leaking Confidential data
C. DoS
D. SQL injection
E. None of these
Correct Answer: E
Explanation
Choice E is the correct Answer. this code is not vulnerable to any of these attacks. This is a trick question
that might appear in the exam.
Choice A is incorrect. The usage of tryWithResources statement ensures that PreparedStatement and
ResultSet objects are closed automatically and hence there is no leakage of resources.
Confidential data leak can happen if sensitive data is logged in log files, exception messages etc. Choice
B is incorrect because no confidential data leaking is possible on this code.
Denial-of-Service (DoS) attack is an explicit attempt to prevent legitimate users from using a service by
hackers. Such an attack typically launched by sending continuous requests to the server for a particular
web resource. Choice C is also incorrect because there is no Denial of Service attack possible here.
SQL injection is a common attack that consists of insertion of SQL code via input data from the client
application. Choice D is incorrect because SQL injection is not applicable here because of the proper use
of PreparedStatement with bind variables here.
Reference: [Link]
Questions: 8 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following are true about annotations?
A. Annotation names are not case sensitive
B. Annotations always contain elements
C. Annotations can be applied to classes, methods, expressions, and annotations
D. When using a marker annotation, parentheses are optional
E. None of these
F. All of these
Correct Answers: C and D
Explanation
Annotations, a form of metadata, provide data about a program that is not part of the program itself.
Annotations have no direct effect on the operation of the code they annotate.
Choice C is correct. Annotations can be applied to declarations: declarations of classes, fields, methods,
and other program elements.
Choice D is also correct. If the annotation has no elements, then the parentheses can be omitted. Such
annotations are called marker annotations.
Choice A is incorrect. Annotation names are case sensitive.
Choice B is incorrect. An annotation can have elements, these look like methods. However, these are
optional. The only purpose is to mark a declaration and hence are called marker annotations.
References: [Link]
[Link]
Questions: 9 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which code fragment when inserted at line 3 will produce the output as “../../[Link]”
1 var path1 = [Link](“[Link]”);
2 var path2 = [Link](“b/[Link]”);
3 // insert code here
A. [Link]([Link](path2));
B. [Link]([Link](path1));
C. [Link]([Link](path1));
D. [Link]([Link](path2));
E. None of these
Correct Answer: B
Explanation
The relativize(Path) method constructs a relative path between the current path and a given path. If both
path values are relative, then the relativize() method computes the paths
as if they are in the same current working directory. Alternatively, if both path values are
absolute, then the method computes the relative path from one absolute location to another,
regardless of the current working directory.
Choice B is correct. To get to [Link] from the current path of b/[Link] , you need to go up two levels (the file
itself counts as one level) and then select [Link]. The output of choice B is “../../[Link]”. Thus choice B is
correct and E is incorrect.
Calling relativize() is on path2 will get to the path b/[Link] from the current path of [Link], resulting in the
output “../b/[Link]”. This is not the expected result and hence choice A is incorrect.
The normalize() method is invoked on a Path object to eliminate unnecessary redundancies in a path. An
empty path is returned if this path does not have a root component and all name elements are redundant.
This method takes no arguments. Hence choices and D will cause compiler errors. Thus choices C and D
are incorrect.
References: [Link]
[Link]
Questions: 10 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What is the result of compiling and running this code?
double d = 1234567.890;
NumberFormat f2 = new DecimalFormat(“$000,000,000.00000”);
[Link]([Link](d));
A. Does not compile
B. Throws exception
C. Prints $001,234,567.89000
D. Prints $1,234,567.89
E. Prints a different result
Correct Answer: C
Explanation
The format method of DecimalFormat accepts a double value as an argument and returns the formatted
number in a String. The pattern parameter passed to the DecimalFormat constructor is the number
pattern that numbers should be formatted according to.
There are 11 Special Pattern Characters, but the most important are:
0 – prints a digit if provided, 0 otherwise
hash – prints a digit if provided, nothing otherwise
. – indicate where to put the decimal separator
, – indicate where to put the grouping separator
In the code fragment given, “$000,000,000.00000” is the format string given. So the output should have a
length of 9 digits before the decimal point and 5 digits after that. To the number 1234567.890, the format
method adds leading and trailing zeros to make the output the desired length, as 0 is used as the pattern
character. Also, a dollar sign is prefixed, as the pattern starts with it. Hence choice C is correct.
If hash was used instead of 0 in the pattern, 1234567.89 would have no trailing or leading zeros
appended to it and D would have been correct. Hence, in this case, option D is incorrect.
Options A and B are incorrect because there are no such errors. As C is correct, choice E is automatically
incorrect.
Reference: [Link]
Questions: 11 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which feature in Java is an attempt to reduce the number of NullPointerExceptions?
A. Optional
B. Enum
C. Predicate
D. Annotation
E. Module
F. None of these
Correct Answer: A
Explanation
Java 8 Optional class allows representing optional values instead of null references. This reduces the
possibility of NullPointerExceptions. Optional can be considered as a single-value container that either
contains a value or doesn’t. The advantage of using Optional as compared to null references is that the
Optional class forces you to think about the case when the value is not present. As a consequence, you
can prevent unintended null pointer exceptions. Thus choice A is correct and F is incorrect.
An enum type is a special data type that enables for a variable to be a set of predefined constants. The
variable must be equal to one of the values that have been predefined for it. It has nothing to do with
NullPointerException and hence choice B is incorrect.
Predicate is a functional interface and can therefore be used as the assignment target for a lambda
expression or method reference. Hence C is also incorrect.
Annotations, a form of metadata, provide data about a program that is not part of the program [Link].
Annotations have no direct effect on the operation of the code. So D is incorrect too.
.A Java module is a packaging mechanism that enables you to package a Java application or Java API as
a separate Java module. So E is incorrect too.
Reference: [Link]
Questions: 12 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What will be the output of this code?
Set<String> colors = new HashSet<>(); //line 1
[Link](“yellow”); //line 2
[Link](“Blue”); //line 3
[Link]((a1, a2) -> [Link](a2)); //line 4
[Link](colors);
A. Prints [yellow, Blue]
B. Exception at runtime
C. Prints [Blue, yellow]
D. Compiler error at line 1
E. Compiler error at line 4
F. None of these
Correct Answer: E
Explanation
A Set is an unordered collection with no duplicate elements. As a HashSet does not maintain the order of
its elements, sorting of HashSet is not possible. However, a List is a sortable collection, which takes a
Comparator, as the argument. A Comparator is an object that defines a compare() method that can be
used to compare two objects, this defines the sort order. However, there is no such sort() method in Set.
Choice E is correct. As the sort() method is not defined for Set implementations, line 4 in the given
example does not compile. The compiler complains that the sort() method is undefined.
Choice A is incorrect. As there is a compiler error in line 4, nothing is printed.
Choice B is incorrect. As the program has a compiler error, a runtime exception cannot be thrown.
Choice C is incorrect because the program cannot be executed due to the compiler error. If the sample
code had List and ArrayList instead of Set and HashSet, the output would have been [Blue, yellow].
Choice D is incorrect. The diamond operator was introduced in Java 7 to simplify instantiation of generic
classes. When the diamond <> operator is used on the right side as in line 1. the compiler can infer that
the class instantiated is to have the same type as the variable it is assigned to. Hence there is no compiler
error in line 1.
Reference: [Link]
Questions:13 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
When will the Student object created on line 3 become eligible for garbage collection?
public class Student { // line 1
public static void main(String[] args) { // line 2
Student one = new Student(); // line 3
Student two = one; // line 4
Student three = two; // line 5
one = null; // line 6
Student four = one; // line 7
two = null; // line 8
three = new Student(); // line 9
[Link](); // line 10
} // Line 11
}
A. After line 6
B. After line 7
C. After line 8
D. After line 9
E. After line 10
F. After line 11
G. None of these
Correct Answer: D
Explanation
The Student object from line 3 has three references to it: one, two and three. The references one and two
are set to null on lines 6 and 8, respectively. The reference three is made to point to a new Student object
in line 9. Hence, there will be no more references after line 9 and is thus eligible for GC (garbage
collection). Hence, choice D is correct.
Choice A is incorrect because only the reference one is set to null after line 6. The references two and
three still point to the object and hence it cannot be garbage collected.
Choice B is incorrect because the reference four is set to null in line 7 and this has no effect on GC.
Choice C is incorrect because only the references one and two are set to null by line 8, the reference
three still points to the object and hence it cannot be garbage collected.
As no more references exist for the object after line 9, the object becomes eligible for GC that time itself.
This makes choices E, F and G incorrect. Also, note that calling [Link]() has no effect on eligibility for
garbage collection.
References: [Link]
[Link]
Questions: 14 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What will be the result?
public static void main(String[] args) {
try {
FileReader fileReader = new FileReader(“c:\\data\\[Link]”);
int data = [Link]();
} catch (IOException | IllegalStateException ex) {
ex = null;
}
}
A. Does not compile because FileReader is not closed after use
B. Does not compile because multiple exceptions cannot be caught in a single catch block
C. Does not compile because IllegalStateException does not extend IOException
D. Does not compile because ex cannot be reassigned to anything
E. Does not compile because null value cannot be assigned to any exception variable
F. Runs without any errors
G. Throws an exception at runtime
Correct Answer: D
Explanation
Java provides a feature named multi-catch blocks in which you can combine multiple catch handlers. The
catch clauses of multiple exceptions can be combined using a single pipe symbol (|). : If a catch block
handles more than one exception type, then the catch parameter is implicitly final, and thus it cannot be
reassigned to anything. Hence ex=null assignment does not compile. Thus, choice D is correct.
Ideally, resources such as FileReader must be closed after use to prevent any resource leak. However,
this does not cause any error while compiling. Hence, choice A is incorrect.
As multiple exceptions can be handled in a multi-catch block, choice B is incorrect. In a multi-catch block,
you cannot combine catch handlers for two exceptions that share a base- and derived-class relationship.
Hence, choice C is incorrect.
Choice E is incorrect because there is no such rule that a null value cannot be assigned to an exception
variable.
As choice D is correct, choices F and G are also incorrect.
Reference: [Link]
Questions: 15 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What is the result of the following code snippet?
public class Switch1 {
private static final String APPLE = “APPLE”;
private static String mango;
public static void main(String[] args) {
String fruit = “Berry”;
mango = “Mango”;
int i = 0;
switch (fruit) {
case “Mango”:
break;
case APPLE:
i++;
default:
i++;
case “VIOLIN”:
i++;
case “BERRY”:
++i;
break;
}
[Link](i);
}
}
A. 0
B. 1
C. 2
D. Throws an exception
E. 3
F. The code does not compile
Correct Answer: E
Explanation
The switch statement is used where there are a number of possible execution paths. It works with the
byte, short, char, and int primitive data types. It also works with enumerated types,the String class, and
some wrapper classes.
In the case of String expressions, the comparison is case sensitive like the [Link] method. Hence,
the value “Berry” does not match the case “BERRY” or any other case. As a result, the default case is
executed, which first increments i to 1. As there is no break statement, the next two cases are also
executed, which result in i being incremented twice more. Thus the value of i is printed as 3. Thus option
E is correct and the other options are incorrect.
As String is a valid expression type in the switch statement. Also, case expressions must be constants.
APPLE is a constant as it is declared as final. Hence, there are no compiler errors or exceptions. So
options D and F are incorrect.
References: [Link]
[Link]
Questions: 16 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What is the security issue in the given code?
public class LibClass {
transient boolean flag = false;
private static final String FILESEPARATOR = “[Link]”;
public static String getPropValue() {
return [Link](new PrivilegedAction<String>() {
public String run() {
return [Link](FILESEPARATOR);
}
});
}
public static void main(String args[]) throws Exception {
try (var ois = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(“[Link]”)))) {
[Link](“Hello”);
}
[Link](getPropValue());
}
}
A. Code is not secure because reading a system property will always result is loss of sensitive data
B. Code is not secure because the system property is retrieved using a hard-coded value
C. Code is not secure because the variable flag is declared transient
D. Code is not secure because the resources are not closed after use
E. There is no such security issue in the code
Correct Answer: E
Explanation
Option E is correct. There is no security issue in the code. No sensitive data is leaked, resources left open
or there is any vulnerability.
Reading a system property might be necessary at times and in such cases privileged code can be given
access only to that specific property, Thus sensitive data can be protected. Hence option A is incorrect.
For safety reasons, the inputs passed to doPrivileged must be restricted to a limited set of acceptable
(usually hard-coded) values. Instead of allowing the code to access any system property, only the given
(hard-coded) system property can be accessed in this code. As this is secure, option B is also incorrect.
Specifying transient variables does not cause any insecurity. In fact, it is advisable to keep sensitive data
transient to prevent it from being serialized. Hence option C is also incorrect.
When closing chained/wrapped streams, we need to close only the outermost stream. In the given code,
ObjectOutputStream is the outermost stream. This and the connected streams are automatically closed
when the try-with-resources block ends. Hence, option D is also incorrect.
Reference: [Link]
Questions: 17 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which annotation can be used to indicate that a method may be removed in a future release?
A. @Retention
B. @SuppressWarnings
C. @Deprecated
D. None of these
Correct Answer: C
Explanation
@Deprecated annotation can be used to indicate that the marked element (module, class, method, or
member) should no longer be used. From Java 9, two optional attributes got added to the @Deprecated
annotation: since and forRemoval. The since attribute defines the Java version in which the element was
marked deprecated first. The default value is an empty string. The forRemoval attribute ( default value is
false) can be specified as true if the element will be removed in the next release. Hence option C is
correct.
@Retention annotation is used to indicate how long annotations with the annotated type are to be
retained. The possible values are below.
SOURCE Used only in the source file, discarded by the compiler
CLASS Stored in the .class file but not available at runtime (default compiler behavior)
RUNTIME Stored in the .class file and available at runtime
As this does not indicate anything about the use of an element in the future versions, option A is incorrect.
The @SuppressWarnings annotation Indicates that the named compiler warnings should be suppressed
in the annotated element (and in all program elements contained in the annotated element). Hence option
B is also incorrect.
Reference: [Link]
Questions: 18 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What is the expected result of executing the following code?
ExecutorService service = null;
Runnable task2 = () -> {
for (int i = 0; i < 3; i++) {
try {
[Link](3000);
} catch (InterruptedException e) {
[Link]();
}
}
};
try {
service = [Link]();
[Link](task2);
[Link](task2);
[Link](task2);
} finally {
if (service != null)
[Link]();
}
[Link](2, [Link]);
[Link](“Done”);
}
A. It will immediately print “Done”
B. It will wait for 2 seconds and then print “Done”
C. It will wait for 3 seconds and then print “Done”
D. It will wait for 5 seconds and then print “Done”
E. It will wait for 9 seconds and then print “Done”
F. Code causes compiler error
G. It will throw an exception at runtime
Correct Answer: B
Explanation
The awaitTermination() method waits the specified time until all tasks have completed execution,
returning earlier if all tasks finish or an InterruptedException is detected.
In the main thread, three tasks are submitted to an ExecutorService. Then the ExecutorService is shut
down. Each task takes at least 3 seconds to complete ([Link]() is called for 3 seconds). As the
awaitTermination() method is invoked passing 2 seconds, it will return with a value of false after two
seconds. Hence, option B is correct and options A, C, D and E are incorrect.
There is no compiler error or exception thrown. Hence, options F and G are incorrect.
Reference:
[Link]
Questions: 19 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following are needed to be used together to prevent SQL Injection attacks while executing
SQL queries?
Use of CallableStatement
Use of PreparedStatement
Passing user-supplied data as bind variables
Passing user-supplied data concatenated to SQL query
Correct Answers: B and C
Explanation
SQL injection is a hacking technique used to exploit an application’s vulnerability by passing user
supplied data as part of an SQL query. To prevent this, PreparedStatement needs to be used by replacing
the values in the bind variables (“?”) within the query with user supplied data. Hence, options B and C are
correct.
Unsanitized user data should never be concatenated with the query, hence option D is incorrect.
Callable statement is used to execute stored procedures and not for SQL queries as specified in the
question. Hence, option A is also incorrect.
Reference: [Link]
Questions: 19 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given
class Test {
public static void main(String[] args) throws IOException {
Path root = [Link](“root”);
Path b = [Link](“root/a/b”);
Path c = [Link](“root/c”);
[Link](b);
[Link](c);
[Link](root).forEach([Link]::println);
}
}
Which of the following can be the given program’s output?
A. b c
B. a a/b c
C. a c a/b
D. root/a root/c root/a/b
E. root root/a root/a/b root/c
F. root root/a root/c root/a/b
Correct Answer: E
Explanation
The Files class includes two methods for walking the directory tree using a depth-first search.
public static Stream<Path> walk(Path start, FileVisitOption… options) throws IOException
public static Stream<Path> walk(Path start, int maxDepth, FileVisitOption… options) throws IOException
The static method walk() uses lazy evaluation and evaluates a Path only as it gets to it.
Here’s a description of the walk method from the Java SE API Specification:
Return a Stream that is lazily populated with Path by walking the file tree rooted at a given starting file.
The file tree is traversed depth-first, the elements in the stream are Path objects that are obtained as if by
resolving the relative path against start.
The stream walks the file tree as elements are consumed. The Stream returned is guaranteed to have at
least one element, the starting file itself.
In the given program, the root directory must be present in the output. Hence, option E is correct.
As the root directory is not present, options A, B, C and D are incorrect.
Option F is also incorrect as the path root/a/b must be right behind the path root/a due to depth-first
traversal.
Reference:
[Link]
h,[Link]…)
Questions: 20 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
int i, j;
for (i = j = 0; ; ++i, j–) {
if (i – j > 10) {
break;
}
}
[Link](i + ” ” + j);
What is the output of the given code?
A. 6 -6
B. 5 -5
C. 4 -4
D. It runs into an infinite loop
E. Compilation fails
Correct Answer: A
Explanation
The for statement is used to iterate over a range of values. It repeatedly loops until a particular condition
is satisfied. The general form of the for statement can be expressed as follows:
for (initialization; termination;
increment) {
statement(s)
}
There is nothing wrong with the given code, hence it compiles without any issues. The variables i and j
are initialized to 0. The body of the for construct keeps running until i – j > 10. This happens when
variables i and j reach 6 and -6, respectively. At this point, the break statement is executed and the for
construct exits. Hence, option A is correct and the others are incorrect.
Reference: [Link]
Questions: 21 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following descriptions about streams is false?
A. A stream is not a data structure that stores elements
B. An operation on a stream produces a result, but does not modify its source
C. Many stream operations can be implemented lazily
D. While collections have a finite size, streams need not
E. An element in a stream can be visited more than once to optimize operations
F. None of the above
Correct Answer: E
Explanation
Here’s an excerpt from the Java 11 API Specification:
Streams differ from collections in several ways:
No storage. A stream is not a data structure that stores elements; instead, it conveys elements from a
source such as a data structure, an array, a generator function, or an I/O channel, through a pipeline of
computational operations. Hence, the description in option A is true, which makes option A incorrect.
Functional in nature. An operation on a stream produces a result, but does not modify its source. For
example, filtering a Stream obtained from a collection produces a new Stream without the filtered
elements, rather than removing elements from the source collection. Hence, the description in option B is
true, which makes option B incorrect.
Laziness-seeking. Many stream operations, such as filtering, mapping, or duplicate removal, can be
implemented lazily, exposing opportunities for optimization. For example, “find the first String with three
consecutive vowels” need not examine all the input strings. Stream operations are divided into
intermediate (Stream-producing) operations and terminal (value- or side-effect-producing) operations.
Intermediate operations are always lazy. Hence, the description in option C is true, which makes option C
incorrect.
Possibly unbounded. While collections have a finite size, streams need not. Short-circuiting operations
such as limit(n) or findFirst() can allow computations on infinite streams to complete in finite time. Hence,
the description in option D is true, which makes option D incorrect.
Consumable. The elements of a stream are only visited once during the life of a stream. Like an Iterator, a
new stream must be generated to revisit the same elements of the source. Hence, the description in
option E is false, which makes option E the correct option.
Reference: [Link]
[Link]
Questions: 22 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
class SuperTest {
public Object myMethod(Object… args) {
// A valid body
}
}
class Test extends SuperTest {
// Method 1
public Object myMethod(String… args) {
// A valid body
}
// Method 2
public Object myMethod(Integer[] args) {
// A valid body
}
// Method 3
public Object myMethod(Object arg) {
// A valid body
}
// Method 4
public String myMethod(Object[] args) {
// A valid body
}
}
Which method in the Test class doesn’t overload the only method in the SuperTest class?
A. Method 1
B. Method 2
C. Method 3
D. Method 4
E. None of the above
Correct Answer: D
Explanation
As per the Oracle Java Specification, an instance method in a subclass with the same signature (name,
plus the number and the type of its parameters) and return type as an instance method in the superclass
overrides the superclass’s method.
Only the method in option D has the same name, number and type of parameters, and return type as the
superclass method, hence this is correct. It is important to note that varargs is just syntactic sugar for
arrays, hence method 4 overrides the super-class’s method.
The first three methods of the Test class don’t have the same parameters as the method in the SuperTest
class, hence they don’t override. Hence, the other options are incorrect.
Reference: [Link]
Questions: 23 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following is NOT true about Runnable and Callable?
A. Both Runnable and Callable can be used to construct a Thread object
B. A Callable task can throw a checked exception, while a Runnable task cannot
C. An ExecutorService can execute a collection of Callable tasks at once
D. When submitting a Runnable, an ExecutorService returns a Future instance
E. None of the above
Correct Answer: A
Explanation
The Thread class doesn’t have a constructor that accepts a Callable argument; hence, option A is false
and hence the correct Answer.
The [Link] method specifies the Exception class in its declaration; thus, it can throw any checked
exception. In contrast, the [Link] method doesn’t specify any exception class and cannot throw a
checked exception. Therefore, option B is true and hence incorrect.
The invokeAll() method of ExecutorService executes the given Callable tasks, returning the result of one
that has completed successfully. The submit() method of ExecutorService Submits a Runnable task for
execution and returns a Future representing that task. Thus, we can see that Options C and D are true
and hence incorrect as per the invokeAll and submit() methods defined in the ExecutorService interface.
References: [Link]
[Link]
[Link]
[Link]
Questions: 25 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Path p = [Link](“[Link]”);
[Link](p, “Hello”); // Line 1
[Link](p, “Goodbye”); // Line 2
[Link]([Link](p));
Suppose the file “[Link]” didn’t exist. What is the given code fragment’s output?
A. Hello
B. Goodbye
C. Hello Goodbye
D. An exception is thrown on line 1
E. An exception is thrown on line 2
Correct Answer: B
Explanation
The writeString(Path, String) is used to write to a file. It takes the Path of the file and a String which is to
be written into the file. It has optional parameters such as charset and open option.
When the [Link] method is called the first time, a file with the specified name is created and
contains the string “Hello”. Subsequently, the second invocation of that method
replaces the existing content with the new string. Therefore, there’s no exception, the final string inside
the given file is “Goodbye”. Thus option B is correct and the others are incorrect.
Reference:
[Link]
[Link],[Link],[Link]…)
Questions: 26 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following isn’t a valid option of the jdeps command?
A. –generate-module-info
B. –generate-open-module
C. –check-deps
D. –list-deps
E. –list-reduced-deps
F. –print-module-deps
Correct Answer: C
Explanation
The jdeps command is used to launch the Java class dependency analyzer.
This is how he command is used.
jdeps [options] path …
Here are descriptions of some options of the jdeps command:
–generate-module-info dir
Generates [Link] under the specified directory. The specified JAR files will be analyzed. This
option cannot be used with –dot-output or –class-path options. Use the –generate-open-module option for
open modules.
–generate-open-module dir
Generates [Link] for the specified JAR files under the specified directory as open modules.
This option cannot be used with the –dot-output or –class-path options.
–check module-name [, module-name…]
Analyzes the dependencies of the specified modules. It prints the module descriptor, the resulting module
dependencies after analysis, and the graph after transition reduction. It also identifies any unused
qualified exports.
–list-deps
Lists the module dependencies and also the package names of JDK internal APIs (if referenced).
–list—reduced-deps
Same as –list-deps without listing the implied reads edges from the module graph. If module M1 reads M2,
and M2 requires transitive on M3, then M1 reading M3 is implied and is not shown in the graph.
–print-module-deps
Same as –list-reduced-deps with printing a comma-separated list of module dependencies. The output
can be used by jlink –add-modules to create a custom image that contains those modules and their
transitive dependencies.
Reference: [Link]
Questions:27 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given
DateFormat formatter = new SimpleDateFormat(“Timezone zz”);
[Link]([Link](“PST”));
Date date = new Date();
String output = [Link](date);
[Link](output);
What is the output of the given code?
A. Timezone -0700
B. Timezone -07:00
C. Timezone PDT
D. Timezone Pacific Daylight Time
E. An IllegalArgumentException is thrown
Correct Answer: E
Explanation
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It
allows for formatting (date → text), parsing (text → date), and normalization.
When you create a SimpleDateFormat object, a pattern String is specified, whose contents determine the
format of the date and time. In a date-time format pattern, all letters (from “A” to “Z” and from “a” to “z”) are
reserved. If we want to include letters in a formatted string, we must put them in single quotes, such as
‘Timezone’.
In the given code, the word Timezone isn’t escaped, hence the program attempts to parse its letters.
Since “T”, the first letter in the word, isn’t a predefined pattern letter, the program fails with an
IllegalArgumentException.
If the pattern string had been escaped correctly, option C would have been the correct Answer.
Reference: [Link]
Questions: 28 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given a module named service, which contains a service interface called [Link]. Its
service provider, [Link], is enclosed in another module called impl.
Which of the following is a correct declaration of the service module?
A. module service { exports [Link]; }
B. module service { requires impl; }
C. module service { exports [Link]; requires impl; }
D. module service { exports [Link]; uses [Link]; }
E. module service { exports [Link]; provides [Link]; }
F. module service { exports [Link]; requires impl; uses [Link]; }
Correct Answer: A
Explanation
A service is composed of an interface, the classes the interface references, and a way of looking up
implementations of the interface. The service provider interface specifies what behavior the service will
have. A service locator is able to find the classes that implement a service provider interface.
When using a service loader, the service interface and its clients know nothing about service providers.
Therefore, the service module shouldn’t have any information about the impl module as well as the
enclosed service provider. Option A is correct as it does not require any module.
Options B and C are incorrect as they require the impl module. In addition, the declaration in option B
doesn’t even export the service interface for public use.
Options D, E and F are incorrect since the directives are incorrectly used.
Reference: [Link]
Questions: 29 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
public class MyResource implements AutoCloseable {
public void open() throws IOException {
throw new IOException(“open”);
}
public void close() {
throw new ArithmeticException(“close”);
}
}
And:
public class Test {
public static void main(String[] args) throws IOException {
try (MyResource myResource = new MyResource()) {
[Link]();
throw new NullPointerException(“try”);
}
}
}
Which exceptions are suppressed when the given program runs and throws an exception?
A. IOException only
B. ArithmeticException only
C. NullPointerException only
D. IOException and ArithmeticException
E. IOException and NullPointerException
F. ArithmeticException and NullPointerException
Correct Answer: B
Explanation
The try-with-resources statement is a try statement that declares one or more resources and ensures that
each resource is closed at the end of the statement, whether an exception occurs or not.
According to the Oracle’s Java Tutorials, if an exception is thrown from the try block and one or more
exceptions are thrown from the try-with-resources statement, then those exceptions thrown from the try-
with-resources statement are suppressed.
In the given code, the close() method is called when the resource is closed. Therefore, the exception
thrown by this method is suppressed. In this case, this exception is ArithmeticException and hence option
B is correct.
The exception propagating up the call stack is the one that is thrown from the try block, which is an
IOException in this case. Hence, D and E are incorrect.
The NullPointerException is not thrown within the close() method and hence, it is also not suppressed.
Hence, option C is also incorrect.
Reference:
[Link]
exceptions
Questions: 30 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
[Link]([Link](null)).findFirst().ifPresent([Link]::println);
What is the output of the given code fragment?
A. Null
B. [Link]
C. Nothing
D. A NoSuchElementException is thrown
E. A NullPointerException is thrown
F. Compilation fails
Correct Answer: B
Explanation
The ifPresent method enables us to run a lambda expression on the wrapped value if it’s found to be non-
null. This method takes a Consumer as the argument and returns void. The ofNullable() method returns
an Optional describing the given value, if non-null, otherwise returns an empty Optional.
The [Link] method produces an empty Optional object since the argument is null. This is the
only element in the stream, hence the [Link] operation returns an Optional object wrapping that
empty Optional. The empty Optional is then printed out by the consumer passed to the [Link]
method. Hence, option B is correct.
As the empty Optional is not null or empty, options A and C are incorrect.
As there are no exceptions or compiler errors, the options D, E and F are incorrect.
Reference: [Link]
Questions: 31 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given service interface MyService and service implementation class MyServiceImpl. Suppose all the
module declarations are valid. Which two of the following are correct ways to get an instance of the
service in the client module?
A. MyService service = new MyServiceImpl();
B. MyService service = [Link]([Link]);
C. MyService service = new ServiceLoader().load([Link]);
D. MyService service = [Link]([Link]);
E. MyService service = [Link]([Link]).findFirst().get();
F. MyService service = [Link]([Link]).iterator().next();
Correct Answers: E and F
Explanation
A ServiceLoader is an object that locates and loads service providers deployed in the run time
environment. Invoking the load() method on the Service Loader creates a new service loader for the given
service. The findFirst() method is invoked to load the first available service provider of this loader’s
service. Hence, options E and F are correct.
When using a service loader, the implementation class isn’t involved in the client code. Instead, it’s loaded
dynamically at runtime. This means options A and D are incorrect.
Option C is incorrect because the ServiceLoader class doesn’t have a public constructor.
Option B is incorrect as the load method returns a ServiceLoader instance rather than an instance of the
implementation class.
Reference: [Link]
Domain: Annotations
Q26. Given:
@SuppressWarnings(“deprecation”)
class Foo {
@SuppressWarnings(“removal”)
void m() {
@SuppressWarnings(“unchecked”)
List list = new ArrayList();
// do something
}
}
Which kinds of warnings are suppressed in statements indicated by the comment // do something?
Options
A. Deprecation only
B. Removal only
C. Unchecked only
D. Deprecation and removal
E. Removal and unchecked
F. Deprecation, removal and unchecked
Answer: D
This annotation specifies which kinds of warnings can be ignored. Applying this annotation to a class,
method, or type basically tells the compiler to suppress any kind of warnings.
Here’s an extract from the Java SE API Specification about the @SuppressWarnings annotation:
Indicates that the named compiler warnings should be suppressed in the annotated element (and in all
program elements contained in the annotated element). Note that the set of warnings suppressed in a
given element is a superset of the warnings suppressed in all containing elements. For example, if you
annotate a class to suppress one warning and annotate a method to suppress another, both warnings will
be suppressed in the method.
As per the explanation above, the suppression of deprecation and removal warnings apply to the whole
body of the m() method in the above code. The unchecked warning is suppressed for the list local variable
only.
Reference:
[Link]
[Link]
Questions: 32 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given a module named service, which contains a service interface called [Link]. Its
service provider, [Link], is enclosed in another module called impl.
Which of the following is a correct declaration of the service module?
Options
A. module service {
exports [Link];
B. module service {
requires impl;
}
C. module service {
exports [Link];
requires impl;
D. module service {
exports [Link];
uses [Link];
E. module service {
exports [Link];
provides [Link];
F. module service {
exports [Link];
requires impl;
uses [Link];
Answer: A
A service is composed of an interface, the classes the interface references, and a way of looking up
implementations of the interface. The service provider interface specifies what behavior the service will
have. A service locator is able to find the classes that implement a service provider interface.
When using a service loader, the service interface and its clients know nothing about service providers.
Therefore, the service module shouldn’t have any information about the impl module as well as the
enclosed service provider. Option A is correct as it does not require any module.
Options B and C are incorrect as they require the impl module. In addition, the declaration in option B
doesn’t even export the service interface for public use.
Options D, E and F are incorrect since the directives are incorrectly used.
Reference:
[Link]
Question No. 1
Questions: 33 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A nothing
B It fails to compile.
C 0
D A [Link] is thrown.
E 10
Correct Answer: B
Question No. 2
Questions: 34 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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 [Link]:public interface API extends AutoCloseable {
E Change Line 2 to an abstract method:public abstract void checkValue(Object value)throws
IllegalArgumentException;
Correct Answer: C, E
Question No. 3
Questions: 35 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two modules include APIs in the Java SE Specification? (Choose two.)
A [Link]
B [Link]
C Javafx
D [Link]
E [Link]
Correct Answer: A, D
Question No. 4
Questions: 36 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the output?
A 300
B Exception
C 200
D 100
Correct Answer: A
Question No. 5
Questions: 37 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two statements are true about the modular JDK? (Choose two.)
A The foundational APIs of the Java SE Platform are found in the [Link] 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.
Correct Answer: A, C
Questions: 38 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. 2-4
• B. 0-6
1-5
2-4
• C. 1-5
• D. 1-5
2-4
• E. The compilation fails due to an error in line 1.
• F. 0-6
• G. 0-6
2-4
Correct Answer: C
Questions: 39 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. 5 4 3 2 1
• B. 5
• C. nothing
• D. 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1
Correct Answer: D
Ref- [Link]
Questions: 40 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
Which two method definitions at line n1 in the Bar class compile? (Choose two.)
• A. public List<Number> foo(Set<String> m) {...}
• B. public List<Integer> foo(Set<CharSequence> m) {...}
• C. public List<Integer> foo(TreeSet<String> m) {...}
• D. public List<Object> foo(Set<CharSequence> m) {...}
• E. public ArrayList<Integer> foo(Set<String> m) {...}
• F. public ArrayList<Number> foo(Set<CharSequence> m) {...}
Correct Answer: BC
Explanations-
B ✅ -> overrides: Same method signature including return type
C ✅ -> overloads: Same method signature including return type, overloads with a subclass as
method parameter
Questions: 41 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. 5
• B. 4
• C. 3
• D. An exception is thrown at runtime
Correct Answer: B
Explanations-
HOWDY <-- [Link]("HOWDY");
*HOWDY <-- [Link](0, "*");
*HOLLY <-- [Link](3, 5, "LL");
*HOLLYCOW <-- [Link](6, "COW");
*HOW <-- [Link](2, 7);
4 <-- [Link]();
Questions: 42 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. 0 8 10
• B. 0
• C. The code prints nothing.
• D. 0 4 9
• E. 0 8
Correct Answer: E
Questions: 43 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
You want to display the value of currency as $100.00.
Which code inserted on line 1 will accomplish this?
• A. NumberFormat formatter = [Link](locale).getCurrency();
• B. NumberFormat formatter = [Link](locale);
• C. NumberFormat formatter = [Link](locale);
• D. NumberFormat formatter = [Link](locale);
Correct Answer: D
Explanations-
D is the correct, as A returned the currency set for the number format.
Ref-
[Link]
Questions: 44 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which three initialization statements are correct? (Choose three.)
• A. int[][][] e = {{1,1,1},{2,2,2}};
• B. short sh = (short)’A’;
• C. float x = 1f;
• D. byte b = 10;
char c = b;
• E. String contact# = “(+2) (999) (232)”;
• F. int x = 12_34;
• G. boolean false = (4 != 4);
Correct Answer: BCF
Explanations-
A is not a 3-Dimensional array
D needs a cast to a char
E is invalid identifier name
G is invalid identifier name as false is a reserved word
Questions: 45 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Your organization makes [Link] available to your cloud customers. While working on a new feature for
[Link], you see that the customer visible method public void enableService(String hostName, String
portNumber) executes this code fragment
and you see this grant is in the security policy file:
What security vulnerability does this expose to your cloud customer's code?
• A. privilege escalation attack against the OS running the customer code
• B. SQL injection attack against the specified host and port
• C. XML injection attack against any mlib server
• D. none because the customer code base must also be granted SocketPermission
• E. denial of service attack against any reachable machine
Correct Answer: B
Explanations-
The correct answer is E. denial of service attack against any reachable machine. The code fragment
shows that the enableService method uses the [Link] method to create a
new Socket with the specified hostname and portNumber. The security policy file grants the
codebase permission to connect to any host using SocketPermission. This means that an attacker
could potentially use this method to repeatedly create connections to any reachable machine,
overwhelming its resources and causing a denial of service attack.
Questions: 46 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
What is the result?
• A. Joe -
null
• B. null
Mary
• C. Joe -
Marry
• D. null
null
Correct Answer: A
Explanations-
It's A. If it would have been p = checkPerson(p);
Then correct answer would have been answer Null and then Mary.
Now it's just checkPerson(p) so p remains "Joe" and then Null.
Questions: 47 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. [A, B, C]
followed by an exception thrown on line 11.
• B. [A, B, C]
[A, B]
• C. [A, B, C]
[A, B, C]
• D. On line 9, an exception is thrown at run time.
Correct Answer: C
Explanations-
C -> the list2 is executed before the runtime
Questions: 48 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which [Link] is correct for a service provider for a print service defined in the PrintServiceAPI
module?
• A. module PrintServiceProvider {
requires PrintServiceAPI;
exports [Link];
}
• B. module PrintServiceProvider {
requires PrintServiceAPI;
provides [Link] with
[Link];
}
• C. module PrintServiceProvider {
requires PrintServiceAPI;
uses [Link];
}
• D. module PrintServiceProvider {
requires PrintServiceAPI;
exports [Link] with
[Link];
}
Correct Answer: B
Explanations-
A service provider module should use the provides directive to declare that it provides an
implementation of a service. The provides directive specifies the service type and the
implementation class. In this case, the PrintServiceProvider module provides an implementation of
the [Link] service with the [Link] class.
Reference- [Link]
Questions: 49 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. EUR -> 0.84 -
GBP -> 0.75 -
USD -> 1.00 -
CNY -> 6.42
• B. The compilation fails.
• C. CNY -> 6.42 -
EUR -> 0.84 -
GBP -> 0.75 -
USD -> 1.00
• D. USD -> 1.00 -
GBP -> 0.75 -
EUR -> 0.84 -
CNY -> 6.42
Correct Answer: C
Questions: 50 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Why would you choose to use a peek operation instead of a forEach operation on a Stream?
• 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
Correct Answer: C
C is the correct answer. Stream<T> peek(Consumer<? super T> action);
peek is an Intermediate Operation and it returns Stream.
Questions: 51 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. abcd
• B. The compilation fails.
• C. adf
• D. abd
• E. abdf
Correct Answer: A
Questions: 52 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
List<Integer> list = [Link](11,12,13,12,13);
Which statement causes a compile time error?
• A. Double d = [Link](0);
• B. double f = [Link](0);
• C. Integer a = [Link]([Link](0));
• D. Integer b = [Link](0);
• E. int c = [Link](0);
• F. Double e = [Link]([Link](0));
Correct Answer: A
Questions: 53 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
Which two are valid usages of the annotation? (Choose two.)
• A. @Meal(mainCourse=”pizza”)
@Meal(dessert=”pudding”)
public class Main {
}
• B. @Meal(mainCourse=null)
public class Main {
}
• C. @Meal(starter=”snack”, dessert=”ice cream”)
public class Main {
}
• D. @Meal(mainCourse=”pizza”)
@Meal(mainCourse=”salad”)
public class Main {
}
• E. @Meal(mainCourse=”pizza”, starter=”snack”, dessert=”pudding”) public class Main {
}
Correct Answer: BE
Questions: 54 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and the code fragment:
Which three code fragments, at line n1, prints SPRING? (Choose three.)
• A. [Link]([Link](“SPRING”).ordinal());
• B. [Link]([Link](1));
• C. [Link]([Link]);
• D. [Link]([Link](“SPRING”));
• E. [Link]([Link](‘s’));
• F. [Link](sA[0]);
• G. [Link](sA[1]);
Correct Answer: CDG
Questions: 55 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which two lines of code when inserted in line 1 correctly modifies instance variables? (Choose two.)
• A. cCount = setCCount(c);
• B. setCCount(c) = cCount;
• C. setGCount(g);
• D. tCount = tCount;
• E. aCount = a;
Correct Answer: AC
Questions: 56 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
You want to print the message こんにちは Joe, 宜しくお願いします, Jane.
Which code inserted on line 1 will accomplish this?
• A. ResourceBundle msg = [Link](“/proj/msg/messages”, new Locale(“ja”,“JP”));
Object[] names = “Joe”, “Jane”);
String message = [Link]([Link](“message”),names);
• B. ResourceBundle msg = [Link](“[Link]”, [Link]);
Object[] names = “Joe”, “Jane”);
String message = [Link]([Link](“message”),names);
• C. [Link]([Link]);
ResourceBundle messages = [Link](“messages”);
String message = [Link]([Link](“message”),“Joe”,“Jane”);
• D. ResourceBundle msg = [Link](“messages”, [Link]);
String[] names = “Joe”, “Jane”);
String message = [Link]([Link](“message”),names);
Correct Answer: D
Questions: 57 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and the commands:
What is the result on execution of these commands?
• A. [Link] - > [Link] -> [Link]
• B. On execution, the jdeps command displays an error.
• C. [Link] -> [Link] -
[Link] - > [Link]
• D. [Link] -> [Link] -
[Link] - > [Link] -
[Link] -> [Link]
Correct Answer: C
Questions: 58 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
A company has an existing Java 8 jar file, [Link], that uses several Apache open source jar files
that have not been modularized.
Which [Link] file should be used to convert [Link] to a module?
• A. module [Link].sales_app {
requires [Link];
requires [Link].collections4;
requires [Link].lang3;
requires [Link];
}
• B. module [Link].sales_app {
requires [Link];
requires [Link].collections4;
requires [Link].lang3;
requires [Link];
}
• C. module [Link].sales_app {
requires [Link];
requires commons.collections4;
requires commons.lang3;
requires [Link];
}
• D. module [Link].sales_app {
requires [Link]-1.9.3;
requires commons.collections4-4.2;
requires commons.lang3-3.8.1;
requires [Link]-1.3;
}
Correct Answer: A
Questions: 59 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two are valid statements? (Choose two.)
• A. BiPredicate<Integer, Integer> test = (final Integer x, var y) -> ([Link](y));
• B. BiPredicate<Integer, Integer> test = (var x, final var y) -> ([Link](y));
• C. BiPredicate<Integer, Integer> test = (Integer x, final var y) -> ([Link](y));
• D. BiPredicate<Integer, Integer> test = (final var x, y) -> ([Link](y));
• E. BiPredicate<Integer, Integer> test = (Integer x, final Integer y) -> ([Link](y));
Correct Answer: BE
Questions: 60 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
What is the result?
• A. Mr. Green
• B. Green
• C. An exception is thrown at runtime.
• D. Mr. Blue
Correct Answer: B
Questions: 61 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
It is required that if p instanceof Pair then [Link]() returns true.
Which is the smallest set of visibility changes to insure this requirement is met?
• A. left, right, setLeft, and setRight must be private.
• B. setLeft and setRight must be protected.
• C. left and right must be private.
• D. isValid must be public.
Correct Answer: A
Questions: 62 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
You want to read data through the reader object.
Which statement inserted on line 1 will accomplish this?
• A. characters = [Link]();
• B. [Link]();
• C. [Link]();
• D. [Link](characters);
Correct Answer: D
Questions: 63 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
Which four identifiers from the Foo and Bar classes are visible at line 1? (Choose four.)
• A. e
• B. f
• C. A
• D. j
• E. d
• F. c
• G. i
• H. B
• I. h
• J. g
Correct Answer: ABDH
Questions: 64 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which code fragment represents a valid Comparator implementation?
• A.
• B.
• C.
• D.
Correct Answer: C
Questions: 65 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Which statement is true?
• A. It never finishes.
• B. The action of CyclicBarrier is called five times.
• C. It finishes without any exception.
• D. Threads in executorService execute for each of the two threads.
Correct Answer: A
Questions: 66 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What prevents this code from compiling?
• A. The calculateSurfaceArea method within Cylinder must be declared default.
• B. Cylinder is not properly calling the Rectangle and Ellipse interfaces’ calculateSurfaceArea
methods.
• C. Cylinder requires an implementation of calculateSurfaceArea with two parameters.
• D. The calculateSurfaceArea method within Rectangle and Ellipse requires a public access modifier.
Correct Answer: C
Questions: 67 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given a Member class with fields for name and yearsMembership, including getters and setters and a print
method, and a list of clubMembers members:
Which two Stream methods can be changed to use method references? (Choose two.)
• A. .filter(Integer::equals(0))
• B. .map(testName::compareToIgnoreCase)
• C. .filter(Member::getYearsMembership() >= testMembershipLength)
• D. .peek(Member::print)
Correct Answer: BD
Questions: 68 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Path p1 = [Link](“/scratch/exam/topsecret/answers”);
Path p2 = [Link](“/scratch/exam/answers/[Link]”);
Path p3 = [Link](“/scratch/answers/topsecret”);
Which two statements print ..\..\..\answers\topsecret? (Choose two.)
• A. [Link]([Link](p1));
• B. [Link]([Link](p3));
• C. [Link]([Link](p3));
• D. [Link]([Link](p2));
• E. [Link]([Link](p2));
• F. [Link]([Link](p1));
Correct Answer: BC
Questions: 69 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Which fields are serialized in a Student object?
• A. studentNo and classes
• B. studentNo and name
• C. studentNo, classes and name
• D. studentNo, classes, name, and address
Correct Answer: A
Questions: 70 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the output?
• A. banana orange apple lemon
-----
apple banana lemon orange
-----
• B. -----
banana orange apple lemon
-----
apple banana lemon orange
• C. -----
-----
• D. -----
-----
banana orange apple lemon apple banana lemon orange
• E. banana orange apple lemon apple banana lemon orange
-----
-----
Correct Answer: D
Questions: 71 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
and
What is the output?
• A. Bonjour le monde!
Bonjour le monde!
• B. Hello world!
Hello world!
• C. Hello world!
Bonjour le monde!
• D. Bonjour le monde!
Hello world!
Correct Answer: C
Questions: 72 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is true?
• A. A NoSuchElementException is thrown at run time.
• B. The compilation fails.
• C. This should print the same result each time the program runs.
• D. This may not print the same result each time the program runs.
Correct Answer: D
Questions: 73 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. The compilation fails.
• B. [0). D, | 1). i, | 2). a]
• C. [). o, | 1). a, | 2).]
• D. [0). o, | 1). i, | 2). r]
• E. ArrayIndexOutOfBounds Exception is thrown at runtime.
Correct Answer: A
Questions: 74 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. An exception is thrown at runtime.
• B. -3
• C. -2
• D. The compilation fails.
Correct Answer: D
Questions: 75 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
You must make the count variable thread safe.
Which two modifications meet your requirement? (Choose two.)
• A. replace line 2 with public static synchronized void main(String[] args) {
• B. replace line 1 with private volatile int count = 0;
• C. replace line 3 with
synchronized(test) {
[Link]++;
}
• D. replace line 1 with private AtomicInteger count = new AtomicInteger(0); and replace line 3 with
[Link]();
• E. replace line 3 with
synchronized([Link]) {
[Link]++;
}
Correct Answer: CD
Questions: 76 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Which action enables Computator class to compile?
• A. change Line 1 to add throws NumberFormatException
• B. change Line 3 to Double sum = 0.0;
• C. change Line 5 to List<Double> numbers = [Link](5, 4, 6, 3, 7, 2, 8, 1, 9);
• D. change Line 2 to public Double sum ( C collection) {
• E. change Line 4 to for (Double n : collection) {
Correct Answer: D
Questions: 77 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. The compilation fails due to an error in line 2.
• B. 201
• C. de
• D. 203
• E. The compilation fails due to an error in line 3.
• F. The compilation fails due to an error in line 1.
Correct Answer: E
Questions: 78 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
public void foo(Function<Integer, String> fun) {...}
Which two compile? (Choose two.)
• A. foo( n -> [Link](n) )
• B. foo( toHexString )
• C. foo( n -> n + 1 )
• D. foo( int n -> [Link](n) )
• E. foo( n -> Integer::toHexString )
• F. foo( Integer::toHexString )
• G. foo( n::toHexString )
• H. foo( (int n) -> [Link](n) )
Correct Answer: AF
Questions: 79 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which declaration of an annotation type is legal?
• A. @interface Author {
String name() default “”;
String date();
}
• B. @interface Author extends Serializable {
String name() default “”;
String date();
}
• C. @interface Author {
String name() default null;
String date();
}
• D. @interface Author {
String name();
String date;
}
• E. @interface Author {
String name();
String date default “”;
}
Correct Answer: A
Questions: 80 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
What is the result?
• A. The program prints Process()called 2.
• B. A [Link] is thrown.
• C. The program prints Process()called 1.
• D. A [Link] is thrown.
• E. The compilation fails.
Correct Answer: A
Questions: 81 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which two interfaces can be used in lambda expressions? (Choose two.)
• A. MyInterface4
• B. MyInterface5
• C. MyInterface1
• D. MyInterface3
• E. MyInterface2
Correct Answer: CD
Questions: 82 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
What is the result?
• A. Good Night, Harry
• B. Good Morning, Potter
• C. Good Morning, Harry
• D. Good Night, Potter
Correct Answer: D
Questions: 83 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What is the result?
• A. 357
• B. 35
• C. 235
• D. 2357
• E. An ArrayIndexOutOfBoundsException is thrown at runtime.
Correct Answer: A
Questions: 84 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which line of code results in a compilation error?
• A. line n1
• B. line n3
• C. line n2
• D. line n4
Correct Answer: D
Questions: 85 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. A [Link] is thrown.
• B. false
• C. A [Link] is thrown.
• D. true
Correct Answer: C
Questions: 86 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and the code fragment:
What is the result?
• A. 9001: [Link]: [Link]
• B. 9001: APPLICATION [Link]
9001: [Link]: [Link]
• C. 9001: APPLICATION [Link]
• D. Compilations fails at Line 1.
Correct Answer: C
Questions: 87 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two interfaces are considered to be functional interfaces? (Choose two.)
• A. @FunctionalInterface
interface InterfaceC {
public boolean equals(Object o);
int breed(int x);
int calculate(int x, int y);
}
• B. @FunctionalInterface
interface InterfaceD {
int breed(int x);
}
• C. @FunctionalInterface
interface InterfaceE {
public boolean equals(int i);
int breed(int x);
}
• D. interface InterfaceA {
int GERM = 13;
public default int getGERM() { return GERM; }
}
• E. interface InterfaceB {
int GERM = 13;
public default int getGERM() { return get(); }
private int get() { return GERM; }
public boolean equals(Object o);
int breed(int x);
}
Correct Answer: BE
Questions: 88 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which code fragment does a service use to load the service provider with a Print interface?
• A. private [Link] loader = [Link]([Link])
• B. private Print print = new [Link]();
• C. private [Link] loader = new [Link]<>()
• D. private Print print = [Link]();
Correct Answer: A
Questions: 89 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
What is the result?
• A. null
• B. HH
• C. Y@<>
• D. The compilation fails
Correct Answer: D
Questions: 90 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which is true?
• A. Code compiles but throws a runtime exception when run.
• B. It prints 666.
• C. The code compiles and runs successfully but with a wrong answer (i.e., a bug).
• D. The code does not compile successfully.
Correct Answer: D
Questions: 91 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
What is the result?
• A. 42
• B. The compilation fails due to an error in line 1.
• C. The compilation fails due to an error in line 2.
• D. The compilation fails due to an error in line 3.
• E. The compilation fails due to an error in line 4.
• F. The compilation fails due to an error in line 5.
• G. 17
Correct Answer: A
Questions: 92 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which statement on line 1 enables this code to compile?
• A. Consumer function = (String f) -> ([Link](f);};
• B. Supplier function = () -> [Link] (0);
• C. Predicate function = a -> [Link]("banana");
• D. Function function = x -> [Link](0,2);
Correct Answer: A
Questions: 93 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. A [Link] is thrown at run time.
• B. Ans : a
• C. The compilation fails.
• D. Ans :
Correct Answer: A
Questions: 94 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the correct definition of the JsonField annotation that makes the Point class compile?
• A.
• B.
• C.
• D.
Correct Answer: C
Questions: 95 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. AnotherClass#methodA()
SomeClass#methodA()
• B. A ClassCastException is thrown at runtime.
• C. The compilation fails.
• D. AnotherClass#methodA()
AnotherClass#methodA()
• E. SomeClass#methodA()
AnotherClass#methodA()
• F. SomeClass#methodA()
SomeClass#methodA()
Correct Answer: C
Questions: 96 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Why does D cause a compilation error?
• A. D does not define any method.
• B. D inherits a() only from C.
• C. D inherits a() from B and C but the return types are incompatible.
• D. D extends more than one interface.
Correct Answer: C
Questions: 97 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Your organization provides a cloud server to your customer to run their Java code. You are reviewing the
changes for the next release and you see this change in one of the config files:
old: JAVA_OPTS="$JAVA_OPTS -Xms8g -Xmx8g"
new: JAVA_OPTS="$JAVA_OPTS -Xms8g -Xmx8g -noverify"
Which is correct?
• A. You accept the change because -noverify is necessary for your code to run with the latest version
of Java.
• B. You reject the change because -Xms8g -Xmx8g uses too much system memory.
• C. You accept the change because -noverify is a standard option that has been supported since Java
1.0.
• D. You reject the change because -noverify is a critical security risk.
Correct Answer: D
Questions: 98 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
and
What needs to change to make these classes compile and still handle all types of Interface Worker?
• A. Replace Line 3 with public void addProcess (Worker w) {.
• B. Replace Line 1 with public class Main extends Thread {.
• C. Replace Line 2 with private List processes = new ArrayList<>();.
• D. Replace Line 3 with public void addProcess(T w) {.
Correct Answer: D
Questions: 99 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the output?
• A. Short value 25
• B. The compilation fails due to an error in line 1.
• C. Byte value 25
• D. Object value 25
Correct Answer: D
Questions: 100 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
You replace the code on line 1 to use ParallelStream.
Which one is correct?
• A. The code will produce the same result.
• B. The compilation fails.
• C. A NoSuchElementException is thrown at run time.
• D. The code may produce a different result.
Correct Answer: D
Questions: 102 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
You want to implement the [Link] interface to the MyPersistenceData class.
Which method should be overridden?
• A. the readExternal method
• B. nothing
• C. the readExternal and writeExternal method
• D. the writeExternal method
Correct Answer: B
Questions: 103 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
Which three are correct? (Choose three.)
• A. [Link](li) prints Hola Mundo!
• B. [Link](li) prints Bonjour le monde!
• C. [Link](li) prints Hello world!
• D. [Link](li) prints Bonjour le monde!
• E. [Link](li) prints Hello world!
• F. [Link](li) prints Bonjour le monde!
• G. [Link](li) prints Hola Mundo!
• H. [Link](li) prints Hola Mundo!
• I. [Link](li) prints Hello world!
Correct Answer: DEH
Questions: 104 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. 10
• B. 1
• C. The compilation fails at line 9.
• D. The compilation fails at line 16.
• E. The compilation fails at line 13.
Correct Answer: E
Questions: 105 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given this enum declaration:
Examine this code:
[Link]([Link]());
What code should be written at line 3 to make this code print A?
• A. static String getFirstLetter() { return [Link]()[1].toString();
• B. static String getFirstLetter() { return [Link](); }
• C. final String getFirstLetter() { return [Link](); }
• D. String getFirstLetter() { return [Link](); }
Correct Answer: B
Questions: 106 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
• A. 5
• B. 11
• C. 15
• D. 21
• E. 23
Correct Answer: C
Questions: 107 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the declaration:
@inteface Resource {
String[] value();
}
Examine this code fragment:
/* Loc1 */ class ProcessOrders { ... }
Which two annotations may be applied at Loc1 in the code fragment? (Choose two.)
• A. @Resource({“Customer1”, “Customer2”})
• B. @Resource(value={{}})
• C. @Resource
• D. @Resource(“Customer1”)
• E. @Resource()
Correct Answer: AD
Questions: 108 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
public interface Builder {
public A build(String str);
}
and
Assuming that this code compiles correctly, which three statements are true? (Choose three.)
• A. A cannot be abstract.
• B. A cannot be final.
• C. B cannot be abstract.
• D. B cannot be final.
• E. B is a subtype of A.
• F. A is a subtype of B.
Correct Answer: BCE
Questions: 109 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the output?
• 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
Correct Answer: D
Questions: 110 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Which can replace line 2?
• A. UnaryOperator u = (int i) -> i * 2;
• B. UnaryOperator u = (var i) -> (i * 2);
• C. UnaryOperator u = var i -> { return i * 2; };
• D. UnaryOperator u = i -> { return i * 2);
Correct Answer: B
Questions: 111 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the content from [Link]:
C-
C++
Java -
Go -
Kotlin -
and
What is the result?
• A. C -
C++
Go -
Kotlin
• B. JAVA
• C. C -
C++
GO -
KOTLIN
• D. C -
C++
JAVA -
GO -
KOTLIN
Correct Answer: D
Questions: 112 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. 1 2 followed by an exception
• B. 1 2 4 5
• C. A ConcurrentModificationException is thrown at run time.
• D. 1 2 3 followed by an exception
Correct Answer: C
Questions: 113 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which change would make Foo more secure?
• A. public String beta = "beta";
• B. public static final String ALPHA = "alpha";
• C. private String delta;
• D. protected final String beta = "beta";
Correct Answer: B
Questions: 114 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
public interface ExampleInterface{ }
Which two statements are valid to be written in this interface? (Choose two.)
• A. public String methodD();
• B. public int x;
• C. final void methodG(){
[Link]("G");
}
• D. final void methodE();
• E. public abstract void methodB();
• F. public void methodF(){
[Link]("F") ;
}
• G. private abstract void methodC();
Correct Answer: AE
Questions: 115 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. hey oh hi
• B. yo ey
• C. A compile time error occurs.
• D. oh hi hey
• E. hey oh hi yo ey
• F. hey oh hi ey
Correct Answer: E
Questions: 116 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which module defines the foundational APIs of the Java SE Platform?
• A. [Link]
• B. [Link]
• C. [Link]
• D. [Link]
Correct Answer: A
Questions: 117 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Integer i = 11;
Which two statements compile? (Choose two.)
• A. Double c = (Double) i;
• B. Double b = [Link](i);
• C. Double a = i;
• D. double e = [Link](i);
• E. double d = i;
Correct Answer: BE
Questions: 118 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and
and
What is the result?
• A. The compilation fails on line 2.
• B. ab action
• C. An exception is thrown at run time.
• D. a action
• E. The compilation fails on line 1.
Correct Answer: B
Questions: 119 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which makes class A thread safe?
• A. Class A is thread safe.
• B. Make foo and setB synchronized.
• C. Make foo synchronized.
• D. Make A synchronized.
• E. Make setB synchronized.
Correct Answer: B
Questions: 120 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
A company has an existing Java app that includes two Java 8 jar files, [Link] and [Link].
The jar file, [Link], references packages in [Link], but [Link] does not reference
packages in [Link].
They have decided to modularize clients-10.2. jar.
Which [Link] file would work for the new library version [Link]?
• A. module [Link]{
requires [Link];
}
• B. module [Link]{
uses [Link];
}
• C. module [Link] {
exports [Link];
}
• D. module [Link] {
exports [Link];
}
Correct Answer: D
Questions: 121 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two statements are correct about modules in Java? (Choose two.)
• A. [Link] cannot be empty.
• B. [Link] can be placed in any folder inside module-path.
• C. By default, modules can access each other as long as they run in the same folder.
• D. A module must be declared in [Link] file,
• E. [Link] exports all of the Java platforms core packages.
Correct Answer: DE
Questions: 122 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Assuming the user credentials are correct, which expression will create a Connection?
• A. [Link]("[Link] "J_SMITH", "dt12%2f3")
• B. [Link]("jdbc:derby:com")
• C. [Link]("[Link]")
• D. [Link]()
• E. [Link]("J_SMITH", "dt12%2f3")
Correct Answer: B
Questions: 123 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which is true? (Choose four.)
• A. The compilation fails due to an error in line 4.
• B. The compilation fails due to an error in line 9.
• C. The compilation fails due to an error in line 10.
• D. The compilation fails due to an error in line 2.
• E. The compilation fails due to an error in line 6.
• F. The compilation fails due to an error in line 7.
• G. The compilation succeeds.
Correct Answer: A, C, E, F
Questions: 124 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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.
Correct Answer: A
Questions: 125 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. abyssinian
oxicat
korat
laperm
bengal
sphynx
• B. abyssinian
bengal
korat
laperm
oxicat
sphynx
• C. sphynx
oxicat
laperm
korat
bengal
abyssinian
• D. nothing
Correct Answer: C
Questions: 126 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
• A. 1.99,2.99,0
• B. 1.99,2.99,0.0
• C. The compilation fails.
• D. 1.99,2.99
Correct Answer: C
Question: 127 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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:
Question: 128 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which two allow [Link] 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: 129 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which interface in the [Link] package will return a void return type?
A. Supplier
B. Predicate
C. Function
D. Consumer
Answer: D
Question: 130 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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: AE
Question: 131 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two commands are used to identify class and module dependencies? (Choose two.)
A. jmod describe
B. java [Link]
C. jdeps --list-deps
D. jar --show-module-resolution
E. java --show-module-resolution
Answer: CE
Question: 132 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. Orange Juice
B. The compilation fails.
C. Orange Juice Apple Pie Lemmon Ice Raspberry Tart
D. The program prints nothing.
Answer: C
Explanation:
Question: 133 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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: 134 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two statements set the default locale used for formatting numbers, currency, and percentages? (Choose
two.)
A. [Link]([Link], “zh-CN”);
B. [Link]([Link], Locale.CANADA_FRENCH);
C. [Link](Locale.SIMPLIFIED_CHINESE);
D. [Link](“en_CA”);
E. [Link](“es”, [Link]);
Answer: BD
Question: 135 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. null
B. nothing
C. It fails to compile.
D. [Link] is thrown.
E. Student
Answer: C
Question: 136 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
You want the code to produce this output:
John
Joe Jane
Which code fragment should be inserted on line 1 and line 2 to produce the output?
A. Insert Comparator<Person> on line
[Link] int compare(Person p1, Person p2) { return [Link]([Link]);}on line 2.
B. Insert Comparator<Person> on line
[Link] int compareTo(Person person) { return [Link]([Link]);}on line 2.
C. Insert Comparable<Person> on line
[Link] int compare(Person p1, Person p2) { return [Link]([Link]);}on line 2.
D. Insert Comparator<Person> on line
[Link] int compare(Person person) { return [Link]([Link]);}on line 2.
Answer: B
Question: 137 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which command line runs the main class [Link] from the module [Link]?
A. java --module-path mods [Link]/[Link]
B. java –classpath [Link] [Link]
C. java --module-path mods -m [Link]/[Link]
D. java -classpath [Link] –m [Link]/[Link]
Answer: D
Question: 138 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
If file "[Link]" is not found, what is the result?
A. Configuration is OK
B. The compilation fails.
C. Exception in thread "main" [Link]:Fatal Error: Configuration File, [Link], is missing.
D. nothing
Answer: B
Explanation:
Question: 139 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. An exception is thrown at runtim
B. 42=(x+y)=42
C. 42=(x+y)=6
D. 6=(x+y)=42
E. 6=(x+y)=6
Answer: D
Explanation:
Question: 140 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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
Question: 141 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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: 142 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Consider this method declaration:
A) “SET SESSION AUTHORIZATION “ + user
B) “SET SESSION AUTHORIZATION “ + [Link](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
Question: 143 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which three actions implement Java SE security guidelines? (Choose three.)
A. Change line 7 to return [Link]();.
B. Change line 4 to [Link] = [Link]();.
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: 144 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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
Question: 137 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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: 144 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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
Question: 145 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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: BE
Question: 146 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which two lines cause compilation errors? (Choose two.)
A. line 12
B. line 6
C. line 9
D. line 8
E. line 7
Answer: BE
Question: 147 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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 policyfile containing this grant.
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
Question: 148 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
What is the result?
A. -1 : 2
B. 2 : -1
C. 2 : 3
D. 3 : 0
Answer: B
Question: 149 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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. [Link] thrown
D. [0,0] = Red[0,1] = White[1,0] = Black[2,0] = Blue[2,1] = Yellow[2,2] = Green[2,3] = Violet
Answer: D
Explanation:
Question: 150 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which code fragment prints 100 random numbers?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: D
Question: 151 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
String originalPath = “data\\projects\\a-project\\..\\..\\another-project”; Path path =
[Link](originalPath);
[Link]([Link]());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:
Question: 151 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. null
B. Joe Bloggs
C. The compilation fails due to an error in line 1.
Answer: C
Explanation:
Question: 152 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
You want to obtain the Stream object on reading the file. Which code inserted on line 1 will accomplish this?
A. var lines = [Link]([Link](INPUT_FILE_NAME));
B. Stream lines = [Link]([Link](INPUT_FILE_NAME));
C. var lines = [Link]([Link](INPUT_FILE_NAME));
D. Stream<String> lines = [Link](INPUT_FILE_NAME);
Answer: C
Question: 153 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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.
Answer: C
Question: 154 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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.
E. Implement only writeReplace to replace the instance with a serial proxy and not readResolve.
Answer: AC
Question: 155 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which two methods facilitate valid ways to read instance fields? (Choose two.)
A. getTCount
B. getACount
C. getTotalCount
D. getCCount
E. getGCount
Answer: CD
Question: 156 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
It is required that if p instanceof Pair then [Link]() 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: 157 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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: 158 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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: AC
Question: 159 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which two are functional interfaces? (Choose two.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: CE
Question: 160 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given this requirement:
Module vehicle depends on module part and makes its [Link] package available for all other modules.
Which [Link] declaration meets the
requirement?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Question: 162 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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()
Answer: C
Explanation:
Question: 163 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which set of commands is necessary to create and run a custom runtime image from Java source files?
A. java, jdeps
B. javac, jlink
C. jar, jlink
D. javac, jar
Answer: B
Question: 164 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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
Question: 165 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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!
Answer: C
Explanation:
Question: 166 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given: [Link]
[Link]
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.
Answer: B
Explanation:
Question: 167 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
/code/a/[Link] containing:
And /code/b/[Link] containing: package b; public class Best { }
Which is the valid way to generate bytecode for all classes?
A. java /code/a/[Link]
B. javac –d /code /code/a/Test
C. java /code/a/[Link] /code/b/[Link]
D. java –cp /code [Link]
E. javac –d /code /code/a/[Link] /code/b/[Link]
F. javac –d /code /code/a/[Link]
Answer: E
Question: 168 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
and:
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 > [Link]()).count();
C. .map(e > [Link]()).collect([Link]()).count();
D. .filter(Employee::getLocality).distinct().count();
Answer: D
Question: 169 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the code fragment:
Path source = [Link](“/repo/a/[Link]”); Path destination = [Link](“/repo”); [Link](source,
destination);
// line 1 [Link] (source); // line 2Assuming the source file and destination folder exist, what Is
the result?
A. A [Link] is thrown on line 1.
B. A [Link] is thrown on line 2.
C. A copy of /repo/a/[Link] is moved to the /repo directory and /repo/a/[Link] is deleted.
D. [Link] is renamed repo.
Answer: C
Question: 170 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which interface in the [Link] package can return a primitive type?
A. ToDoubleFunction
B. Supplier
C. BiFunction
D. LongConsumer
Answer: A
Question: 171 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Assume the file on path does not exist. What is the result?
A. The compilation fails.
B. /u01/work/[Link] is not deleted.
C. Exception
D. /u01/work/[Link] is deleted.
Answer: A
Explanation:
Question: 172 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
List<String> longlist =
[Link](“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: 173 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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: 175 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the type of x?
A. char
B. List<Character>
C. String
D. List<String>
Answer: C
Question: 176 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. 42
B. The compilation fails due to an error in line 4.
C. 17
D. The compilation fails due to an error in line 3.
E. The compilation fails due to an error in line 2.
F. The compilation fails due to an error in line 1.
G. The compilation fails due to an error in line 5.
Answer: A
Question: 177 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
Which expression when added at line 1 will produce the output of 1.17?
A. float z = (float)([Link]((float)x/y*100)/100);
B. float z = [Link]((int)(x/y),2);
C. float z = [Link]((float)x/y,2);
D. float z = [Link]((float)x/y*100)/(float)100;
Answer: D
Explanation:
Question: 178 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the contents:
[Link] 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=Bonjourand the code fragment:
[Link]([Link]);
Locale currentLocale = new [Link]().setLanguage(“en”).build();
ResourceBundle messages = [Link](“MessageBundle”, currentLocale);
[Link]. println([Link](“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. [Link]
Answer: C
Question: 179 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
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 [Link] is thrown.
Answer: D
Question: 180 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which code fragment compiles?
A. Option A
B. Option B
C. Option C
D. O
i
o
Question: 181 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. The compilation fail
B. 1.99,2.99,0
C. 1.99,2.99,0.0
D. 1.99,2.99
Answer: A
Explanation:
Question: 182 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
var fruits = [Link](“apple”, “orange”, “banana”, “lemon”);
You want to examine the first element that contains the character n. Which statement will accomplish this?
A. String result = [Link]().filter(f > [Link](“n”)).findAny();
B. [Link]().filter(f > [Link](“n”)).forEachOrdered([Link]::print);
C. Optional<String> result = [Link]().filter(f > [Link] (“n”)).findFirst ();
D. Optional<String> result = [Link]().anyMatch(f > [Link](“n”));
Answer: B
Explanation:
Question: 183 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given this enum declaration:
Examine this
code:
[Link].p
rintln(Alphab
[Link]
ter());What
code should
be written at
line 3 to
make this
code print A?
A. final String getFirstLetter() { return [Link](); }
B. static String getFirstLetter() { return [Link]()[1].toString(); }
C. static String getFirstLetter() { return [Link](); }
D. String getFirstLetter() { return [Link](); }
Answer: C
Question: 184 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the given options if put at //1 will correctly
instantiate objects of various classes defined in the following
code?
public class TestClass
{
public class A{
}
public static class B {
}
public static void main(String args[]){
class C{
}
//1
}
}
Select 2 options:
1. new TestClass().new A();
2. new TestClass().new B();
3. new TestClass.A();
4. new C();
5. new TestClass.C();
Correct Answers: 1, 4
Explanations-
class A is not static inner class of TestClass. So it canno exist
without an outer instance of TestClass. So, option 1 is the right
way to instantiate it.
class B is static inner class and can be instantiated like this:
new TestClass.B(). But new TestClass().new B() is not correct.
Although not related to this question, unlike popular belief,
anonymous class can never be static. Even if created in a
static method.
Question: 185 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What will the following code print when compiled and run?
public class TestClass{
public static int operate(IntUnaryOperator iuo){
return [Link](5);
}
public static void main(String[] args) {
IntFunction<IntUnaryOperator> fo = a->b->a-b; //1
var x = operate([Link](20)); //2
[Link](x);
}
}
Select 1 best option:
1. Compilation error at //1
2. Compilation error at //2
3. 15
4. -15
5. 20
6. Exception at run time
Correct Answer: 3
Explanations-
The lambda expression a->b->a-b looks complicated but it is
actually simple if you group it like this:
a->(b->a-b);
1. IntFunction is a functional interface that takes an int and
returns whatever it is typed to. Here, the IntFunction is typed
to IntUnaryOperator.
Therefore, IntFunction<IntUnaryOperator> will take in
an int and return IntUnaryOperator.
The general form of a lambda expression that
captures IntFunction would be x->line of code that returns the
correct return type i.e. IntUnaryOperator, in this
case; where x is an int.
Now, if you look at fo = a->b->a-b;, a is the argument variable
of type int (because it is being used to capture IntFunction)
and b->a-b forms the method body of the IntFunction. b->a-
b must somehow return an IntUnaryOperator for fo = a->b-
>a-b; to work.
2. IntUnaryOperator is a functional interface that takes in
an int and returns another int. It cannot be typed to anything
else because both the input and the output are already
defined to be int.
The general form of a lambda expression that
captures IntUnaryOperator would be y->line of code that
returns an int; where y is an int.
Now, in the case of b->a-b; you can see that b is the
argument variable and a-b is the method body. For a-b to
capture IntUnaryOperator, a must already be defined and it
must be an int. Only then will a-b return an int (which is
required to capture IntUnaryOperator). That is indeed the
case because a is already defined as the argument variable
of the encompassing lambda expression and is available for
use within the method body of that expression.
3. So basically, when you call [Link](20), you are
setting a to 20. Therefore, [Link](20) returns
an IntUnaryFunction that returns 20-b, where b is the
argument passed to the IntUnaryFunction. When you
call [Link](5); b is being set to 5.
Therefore [Link](5) will return 20-5 i.e. 15.
Question: 186 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
public class Student {
public static enum Grade{ A, B , C, D, F}
private String name;
private Grade grade;
public Student(String name, Grade grade){
[Link] = name;
[Link] = grade;
}
public String toString(){
return name+":"+grade;
}
//getters and setters not shown
}
What can be inserted in the code below so that it will print:
{C=[S3], A=[S1, S2]}
List<Student> ls = [Link](new Student("S1",
[Link].A), new Student("S2", [Link].A), new
Student("S3", [Link].C));
//INSERT CODE HERE
[Link](grouping);
Select 1 best option:
1. Map<[Link], List<Student>> grouping =
[Link]().collect(
[Link](Student::getGrade),
[Link](Student::getName,
[Link]())));
2. Map<[Link], List<String>> grouping =
[Link]().collect(
[Link](Student::getGrade,
[Link](Student::getName,
[Link]())));
3. Map<[Link], List<String>> grouping =
[Link]().collect(
[Link](Student::getGrade,
[Link](Student::getName,
[Link]())));
4. Map<[Link], List<String>> grouping =
[Link]().collect(
[Link](Student::getGrade,
[Link](Student::getName)));
Correct Answer: 3
Question: 187 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
The developer of a method that accesses the file system
wants to ensure that the caller has appropriate permissions.
She has written the following code:
public class FileOps {
public static void doOps() {
return [Link](
new PrivilegedAction<String>() {
public String run() {
//do File operations here
}
}, [Link]()
);
}
}
What, if anything, is wrong with this code from a security
perspective?
Select 1 best option:
1. This code does not really check the permissions of the
caller.
2. This code violates secure coding guidelines because it
does not check the return value
of [Link]() for null.
3. This code is fine and does not violate secure coding
guidelines.
4. It should
use [Link]() instead
of [Link]() as the second
argument to doPrivileged.
Correct Answer: 3
Question: 188 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
What will the following code print if file [Link] exists
but [Link] doesn't exist?
public class FileCopier {
public static void copy1(Path p1, Path p2) throws
Exception {
[Link](p1, p2,
StandardCopyOption.COPY_ATTRIBUTES,
StandardCopyOption.REPLACE_EXISTING);
}
public static void main(String[] args) throws Exception {
var p1 = [Link]("c:\\temp\\[Link]");
var p2 = [Link]("c:\\temp\\[Link]");
copy1(p1, p2);
if([Link](p1, p2)){
[Link]("file copied");
}else{
[Link]("unable to copy file");
}
}
}
Select 1 best option:
1. An exception at run time if either of p1 or p1 is a
symbolic link.
2. It will print file copied and [Link] will contains the
same data as [Link].
3. It will print file copied but [Link] will NOT contain the
same data as [Link].
4. It will print unable to copy file but [Link] will contain
the same data as [Link].
5. It will print unable to copy file and [Link] will not be
created.
Correct Answer: 4
Explanations-
[Link] method will copy the file [Link] into [Link]. If
[Link] doesn't exist, it will be created.
However, [Link] method doesn't check the
contents of the file. It is meant to check if the two path objects
resolve to the same file or not. In this case, they are not, and
so, it will return false.
The following is a brief JavaDoc description for both the
methods:
public static Path copy(Path source, Path target,
CopyOption... options)
throws IOException
Copy a file to a target file.
This method copies a file to the target file with the options
parameter specifying how the copy is performed. By default,
the copy fails if the target file already exists or is a symbolic
link, except if the source and target are the same file, in
which case the method completes without copying the file.
File attributes are not required to be copied to the target file.
If symbolic links are supported, and the file is a symbolic link,
then the final target of the link is copied. If the file is a
directory then it creates an empty directory in the target
location (entries in the directory are not copied).
The options parameter may include any of the following:
REPLACE_EXISTING If the target file exists, then the
target file is replaced if it is not a non-empty directory. If the
target file exists and is a symbolic link, then the symbolic link
itself, not the target of the link, is replaced.
COPY_ATTRIBUTES Attempts to copy the file attributes
associated with this file to the target file. The exact file
attributes that are copied is platform and file system
dependent and therefore unspecified. Minimally, the last-
modified-time is copied to the target file if supported by both
the source and target file store. Copying of file timestamps
may result in precision loss.
NOFOLLOW_LINKS Symbolic links are not followed. If the
file is a symbolic link, then the symbolic link itself, not the
target of the link, is copied. It is implementation specific if file
attributes can be copied to the new link. In other words,
the COPY_ATTRIBUTES option may be ignored when
copying a symbolic link.
An implementation of this interface may support additional
implementation specific options.
Copying a file is not an atomic operation. If an IOException is
thrown then it possible that the target file is incomplete or
some of its file attributes have not been copied from the
source file. When the REPLACE_EXISTING option is
specified and the target file exists, then the target file is
replaced. The check for the existence of the file and the
creation of the new file may not be atomic with respect to
other file system activities.
public static boolean isSameFile(Path path, Path path2)
throws IOException
Tests if two paths locate the same file.
If both Path objects are equal then this method returns true
without checking if the file exists. If the two Path objects are
associated with different providers then this method returns
false. Otherwise, this method checks if both Path objects
locate the same file, and depending on the implementation,
may require to open or access both files.
Question: 189 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following lines will cause the compilation to
fail??
public enum EnumA{ A, AA, AAA}; //1
public class TestClass //2
{
public enum EnumB{ B, BB, BBB }; //3
public static enum EnumC{ C, CC, CCC }; //4
public TestClass()
{
enum EnumD{ D, DD, DDD } //5
}
public void methodX()
{
public enum EnumE{ E, EE, EEE } //6
}
public static void main(String[] args) //7
{
enum EnumF{ F, FF, FFF}; //8
}
}
Select 4 options:
1. 1, 2, or both depending on the file name.
2. 3
3. 4
4. 5
5. 6
6. 7
7. 8
Correct Answers: 1, 4, 5, 7
Question: 190 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
var qr = "insert into USERINFO values( ?, ?, ?)";
try(PreparedStatement ps = [Link](qr);)
{
[Link](1, 1, [Link]);
[Link](2, "Ally A", [Link]);
[Link](3, "101 main str", [Link]);
var i = [Link](); //1
[Link](1, 2, [Link]);
[Link](2, "Bob B", [Link]);
i = [Link](); //2
}
What will be the result?
Select 1 best option:
1. An exception will be thrown at //1
2. An exception will be thrown at //2
3. Two rows with the following values will be inserted in
the USERINFO table:
1, Ally A, 101 main str
2, Bob B, null
4. Two rows with the following values will be inserted in
the USERINFO table:
1, Ally A, 101 main str
2, Bob B, 101 main str
5. One row with the following values will be inserted in
the USERINFO table:
1, Ally A, 101 main str
and an exception will be thrown at //2.
Correct Answer: 4
Explanations-
This question is based on the fact that a PreparedStatement
remembers the values that you set for every parameter until
you close that PreparedStatement object (by calling close()
on it). So, if you execute the same query multiple times with
same values for some columns, you don't need to set the
values for those columns again and again. Setting them once
is fine. You need to set values for only those columns that
require a change.
Question: 191 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the following module-info:
module book{
requires [Link];
uses [Link];
}
Which of the following statements are correct?
Select 1 best option:
1. book module can be compiled without requiring any
module that provides Print service.
2. At least one implementation of Print service must be
available on module-source-path for book module to
compile.
3. At least one implementation of Print service must be
available for book module to execute without an
exception.
4. At least one implementation of Print service must be
available for book module to load successfully at run
time.
5. The requires [Link]; clause in the given module-info
is redundant.
Correct Answer: 1
Question: 192 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Consider the classes shown below:
class A{
public A() { }
public A(int i) { [Link](i ); }
class B{
static A s1 = new A(1);
A a = new A(2);
public static void main(String[] args){
var b = new B();
var a = new A(3);
static A s2 = new A(4);
Which is the correct sequence of the digits that will be printed
when B is run?
Select 1 best option:
1. 1 ,2 ,3 4.
2. 1 ,4, 2 ,3
3. 3, 1, 2, 4
4. 2, 1, 4, 3
5. 2, 3, 1, 4
Correct Answer: 2
1. All static constants, variables, and blocks. Among
themselves the order is the order in which they appear in the
code. This step is actually a part of "class initialization" rather
than "instance initialization". Class initialization happens only
if the class is being used for the first time while being
instantiated. For example, if you have invoked a static
method of a class or accessed a static field of that class
earlier in the code, you have already used the class and the
JVM would have performed initialization of this class at that
time. Thus, there wouldn't be any need to initialize the class if
you instantiate an object of this class now.
Further, if the class has a superclass, then the JVM performs
this step for the superclass first (if the superclass hasn't been
initialized already) and only after the superclass is initialized
and static blocks are executed, does the JVM proceed with
this class. This process is followed recursively up to the
[Link] class.
2. All non static constants, variables, and blocks. Among
themselves the order is the order in which they appear in the
code.
3. Constructor.
Just like the class initialization, instance initialization also
happens for the superclass first. That is, if the class has a
superclass, then the JVM takes steps 2 and 3 given above
for the superclass first and only after the superclass's
instance members are initialized, does the JVM proceed with
this class. This process is also followed recursively up to the
[Link] class.
Question: 193 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given the following class:
class Person{
private String name;
private [Link] dob;
public Person(String name, [Link] dob){
[Link] = name;
[Link] = dob;
}
//public getters and setters for name and dob
and the following method appearing in some other class:
public List<Person> getEligiblePersons(List<Person>
people){
var pl = new ArrayList<Person>();
for(var p : people){
if([Link]().isBefore(cutoff)){
[Link](p);
}
}
return pl;
}
Select 2 options:
1. There is no issue with the given code.
2. A copy of dob parameter should be made and that
copy should be assigned to the dob field.
3. getEligiblePersons should create a deep copy of
the people list before processing the elements.
4. Person class should provide a copy constructor.
5. Person class should be made final.
Correct Answers: 3, 4
Question: 194 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given :
//1
public class TestClass {
//2
public static void main(String[] args) throws Exception{
var al = new ArrayList<Integer>();
printElements(al);
}
//3
static void printElements(List<Integer>... la) {
for(List<Integer> l : la){
[Link](l);
}
}
}
Which option(s) will get rid of compilation warning(s) for the
above code?
Select 1 best option:
1. Apply @SuppressWarnings("all") at //1
2. Apply @SuppressWarnings("unchecked") at //2
3. Apply @SuppressWarnings("rawtypes") at //2
4. Apply @SuppressWarnings("rawtypes") at //3
5. Apply @SuppressWarnings("unchecked") at //2 as
well as //3.
6. Apply @SuppressWarnings("rawtypes") at //2 as well
as //3.
Correct Answer: 5
Question: 195 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Which of the following statements are correct regarding
abstract classes and interfaces?
Select 2 options:
1. An abstract class can have private as well as static
methods while an interface can not have static
methods.
2. An abstract class cannot implement multiple interfaces
while an interface can extend multiple interfaces.
3. Abstract classes can have abstract methods but
interface cannot.
4. Abstract classes can have instance fields but
interfaces can't.
5. An abstract class can have final methods but an
interface cannot.
Correct Answers: 4, 5
Question: 196 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
//assume appropriate imports
public class Calculator{
public static void main(String[] args) {
double principle = 100;
int interestrate = 5;
double amount = compute(principle, x->x*interestrate);
}
INSERT CODE HERE
}
Which of the following methods can be inserted in the above
code so that it will compile and run without any
error/exception?
Select 2 options:
1. public static double compute(double base,
Function<Integer, Integer > func){
return [Link]((int)base);
}
2. public static double compute(double base,
Function<Integer, Double> func){
return [Link]((int)base);
}
3. public static double compute(double base,
Function<Double, Integer> func){
return [Link](base);
}
4. public static double compute(double base,
Function<Double, Double> func){
return [Link](base);
}
5. public static double compute(double
base, Function<Integer, Double> func){
return [Link](base);
}
Correct Answers: 1, 4
Explanations-
The lambda expression x->x*interestrate basically takes an
input value, modifies it, and return the new value. It is,
therefore, acting as a Function.
Therefore, you need a method named compute that takes
two arguments - an double value and a Function instance.
Option 1 and 4 provide just such a method.
Question: 197 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Consider the following code:
class Account{
private String id; private double balance;
ReentrantLock lock = new ReentrantLock();
public void withdraw(double amt){
try{
[Link]();
if(balance > amt) balance = balance - amt;
}finally{
[Link]();
}
}
}
What can be done to make the above code thread safe?
Select 1 best option:
1. Change new ReentrantLock() to new ReentrantLock(true).
2. Move the call to [Link](); to before the try block.
3. Declare lock variable as private and final.
4. Make the lock variable private, final, and static.
5. Make the lock variable static.
6. No change is required.
Correct Answer: 3
Question: 198 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Your application uses one modular jar ([Link]), which, in turn,
uses one non-modular jar ([Link]). Which of the following
commands will cause jdeps to include the non-modular jar in
its analysis?
Select 1 best option:
1. jdeps -module-path lib\[Link]; -classpath lib\[Link]
2. jdeps --module-path lib\[Link]; lib\[Link]
3. jdeps --class-path lib\[Link]; lib\[Link]
4. jdeps -cp lib\[Link] lib\[Link]
5. jdeps -cp lib\[Link];lib\[Link]
Correct Answer: 3
Explanation-
Please go through the documentation for jdeps given here:
[Link]
jdeps can analyze one or multiple class file(s) or jar file(s). If
a given target file depends on a module, then that module
must be specified on --module-path (or -p). If the given target
file depends on a non-modular jar file (or a class ), then that
jar (or class) must be specified on -classpath (or --class-path
or -cp).
Question: 199 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Consider the following piece of code:
[Link](new Locale("fr", "CA")); //Set default
to French Canada
Locale l = new Locale("jp", "JP");
ResourceBundle rb =
[Link]("appmessages", l);
String msg = [Link]("greetings");
[Link](msg);
You have created two resource bundle files with the following
contents:
#In [Link]:
greetings=Hello
#In appmessages_fr_FR.properties:
greetings=bonjour
Given that this code is run on machines all over the world.
Which of the following statements are correct?
Select 1 best option:
1. It will throw an exception when the default locale of
the machine where it is run is different from fr/FR and
fr/CA.
2. It will throw an exception where ever it is run.
3. It will throw an exception when the default locale of
the machine is fr/CA.
4. It will throw an exception when the default locale of
the machine is jp/JP.
5. It will run without any exception all over the world.
Correct Answer: 5
Explanation-
While retrieving a message bundle, you are passing a locale
explicitly (jp/JP). Therefore, it will first try to load
appmessages_jp_JP.properties. Since this file is not present,
it will look for a resource bundle for default locale. Since you
are changing the default locale to "fr", "CA", it will look for
appmessages_fr_CA.properties, which is also not present.
Remember that when a resource bundle is not found for a
given locale, the default locale is used to load the resource
bundle. Every effort is made to load a resource bundle if one
is not found and there are several fall back options (in
absence of appmessages_fr_CA.properties, it will look for
appmessages_fr.properties). As a last resort, it will try to load
a resource bundle with no locale information i.e.
[Link] in this case. (An exception is thrown
when even this resource bundle is not found.)
Since [Link] is available, the code will
never throw an exception in any locale.
You need to understand this aspect for the purpose of the
exam. Please go through
[Link]
[Link]#getBundle([Link],%[Link],%
[Link]) for further details.
Question: 200 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
Given:
What is the result?
A. nothing
B. It fails to compile.
C. 0
D. A [Link] is thrown.
E. 10
Correct Answer -B
Explanation
Answer: B
Question: 201 Java SE 11 Developer 1Z0-819 Actual Exam Q&A | CLEARCATNET
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 [Link]:public interface
API extends AutoCloseable {
E. Change Line 2 to an abstract method:public abstract void
checkValue(Object value)throws IllegalArgumentException;
Answer: C,E
VISIT US – [Link]