27 free Oracle 1Z0-819 practice questions from the CertStash pack of 213, each with the correct answer and a full explanation. The rule is the same for every exam: ten free on the product page, 27 free here, all 213 in the pack, and each step includes the one before it.
Get all 213 questions (US$39) · Download the first 10 as a PDF
Question 1
Which two interfaces are considered to be functional interfaces? (Choose two.)
Show answer and explanation
Correct answer: B, E. @FunctionalInterface interface InterfaceD { int breed(int x); }; 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); }
A functional interface has exactly one abstract method, and abstract methods that match public methods of Object, such as equals(Object), do not count. InterfaceD has only breed. InterfaceB has default and private methods plus equals(Object), leaving breed as its single abstract method, so it is functional even without the annotation.
Why the other options are wrong
- A. InterfaceC has two abstract methods, breed and calculate, so the @FunctionalInterface annotation causes a compile error.
- C. equals(int) does not override Object.equals(Object), so InterfaceE has two abstract methods.
- D. InterfaceA has no abstract method at all, only a default method and a constant.
Question 2
Which code fragment does a service use to load the service provider with a Print interface?
Show answer and explanation
Correct answer: A. private java.util.ServiceLoader loader = ServiceLoader.load(Print.class)
ServiceLoader.load(Print.class) is the correct way to load a service provider. It returns a ServiceLoader instance that can iterate over all implementations of the Print service found on the module path or classpath. Option B uses direct instantiation, which bypasses the service provider mechanism. Option C attempts to instantiate ServiceLoader with the diamond operator, which is incorrect syntax and defeats the purpose. Option D uses a static factory method pattern that is not part of the standard ServiceLoader API.
Why the other options are wrong
- B. Direct instantiation with 'new' bypasses the ServiceLoader mechanism entirely and doesn't support service discovery.
- C. ServiceLoader cannot be instantiated directly with the diamond operator; it must be loaded via the static load() method.
- D. The getInstance() pattern is not how ServiceLoader works; ServiceLoader uses the static load() factory method instead.
Question 3
Which three initialization statements are correct? (Choose three.)
Show answer and explanation
Correct answer: B, C, F. short sh = (short)’A’;; float x = 1f;; int x = 12_34;
Option B is correct because a char can be initialized with a cast short value, and the cast is valid. Option C is correct because the f suffix denotes a float literal, which is the proper way to initialize a float variable. Option F is correct because numeric literals can use underscores as separators for readability (introduced in Java 7), making 12_34 equivalent to 1234. Option A is incorrect because a 3D array cannot be initialized with a 2D array literal. Option D is incorrect because you cannot assign a byte directly to a char without an explicit cast. Option E is incorrect because identifiers cannot contain the # symbol. Option G is incorrect because false is a reserved keyword in Java and cannot be used as a variable name.
Why the other options are wrong
- A. A 3D array type cannot be initialized with 2D array literals.
- D. Byte cannot be assigned to char without an explicit cast.
- E. The # character is not allowed in identifier names.
- G. false is a reserved keyword and cannot be used as a variable name.
Question 4
Which module-info.java is correct for a service provider for a print service defined in the PrintServiceAPI module?
Show answer and explanation
Correct answer: B. module PrintServiceProvider { requires PrintServiceAPI; provides org.printservice.spi.Print with com.provider.PrintService; }
The correct module-info.java for a service provider uses the provides-with statement to indicate which service interface (org.printservice.spi.Print) is implemented by which provider class (com.provider.PrintService). The requires statement correctly imports the PrintServiceAPI module. Option A is incorrect because exports is used for exposing packages, not for declaring service implementations. Option C is incorrect because uses is for service consumers, not providers. Option D is incorrect because the exports-with syntax does not exist; the correct syntax is provides-with for service declarations.
Why the other options are wrong
- A. exports is for exposing packages to other modules, not for declaring service providers.
- C. uses keyword is for service consumers declaring their dependency on a service, not for providers.
- D. The exports-with syntax does not exist in the module system; provides-with is the correct syntax.
Question 5
Why would you choose to use a peek operation instead of a forEach operation on a Stream?
Show answer and explanation
Correct answer: C. to process the current item and return a stream
The peek operation is an intermediate operation that returns a stream, allowing you to inspect elements while maintaining the stream pipeline. This enables further stream operations to be chained after peek. In contrast, forEach is a terminal operation that returns void and ends the stream. Peek is valuable when you need to process an element for debugging or side effects while continuing the stream chain. Option A is incorrect because peek does return a stream, not void. Options B and D are incorrect because peek does not remove elements from anywhere in the stream.
Why the other options are wrong
- A. peek returns a stream, not void; it is an intermediate operation, not terminal.
- B. peek does not remove items; it is used for inspection during stream processing.
- D. peek does not remove items from the beginning; it processes all elements in order.
Question 6
Given the code fragment: List<Integer> list = List.of(11,12,13,12,13); Which statement causes a compile time error?
Show answer and explanation
Correct answer: A. Double d = list.get(0);
Option A causes a compile-time error because list.get(0) returns an Integer (boxed type), and assigning it to a Double reference is not valid. There is no implicit conversion from Integer to Double; they are distinct reference types. Option B compiles because the Integer is unboxed to int, then auto-unboxed to double. Option C compiles because Integer.valueOf() explicitly returns an Integer. Option D compiles because Integer is directly assigned to Integer. Option E compiles because int unboxes from Integer. Option F compiles because Double.valueOf() accepts an int parameter (from unboxing) and converts it to Double.
Why the other options are wrong
- B. The Integer unboxes to int, which then widens to double; this is valid.
- C. Integer.valueOf() explicitly returns Integer, which matches the target type.
- D. Direct assignment of Integer to Integer reference is always valid.
- E. Integer unboxes to int, which is then assigned to the int variable.
- F. Double.valueOf() accepts an int and converts it to Double.
Question 7
Which two are valid statements? (Choose two.)
Show answer and explanation
Correct answer: B, E. BiPredicate<Integer, Integer> test = (var x, final var y) -> (x.equals(y));; BiPredicate<Integer, Integer> test = (Integer x, final Integer y) -> (x.equals(y));
Option B is valid because var can be used with the final modifier in lambda parameters, allowing var x and final var y as parameter declarations. Option E is valid because explicit types can be combined with the final modifier, making final Integer y a legal parameter. Option A is invalid because mixing final Integer with var y is not allowed; parameters must use consistent declaration styles. Option C is invalid because mixing an explicit type Integer with final var is not permitted. Option D is invalid because if you use var, all parameters in the lambda must use var or explicit types without mixing, and y cannot omit the var keyword.
Why the other options are wrong
- A. Mixing final Integer and var in the same lambda parameter list is not allowed.
- C. You cannot mix explicit type Integer with var type in the same parameter list.
- D. When using var for one parameter, the other parameter y cannot omit a type declaration.
Question 8
Given: Path p1 = Paths.get(“/scratch/exam/topsecret/answers”); Path p2 = Paths.get(“/scratch/exam/answers/temp.txt”); Path p3 = Paths.get(“/scratch/answers/topsecret”); Which two statements print ..\..\..\answers\topsecret? (Choose two.)
Show answer and explanation
Correct answer: B, C. System.out.print(p2.relativize(p3));; System.out.print(p1.relativize(p3));
The relativize method computes the relative path from the calling path to the argument path. Option B: p2.relativize(p3) computes the path from /scratch/exam/answers/temp.txt to /scratch/answers/topsecret, resulting in ..\..\.\answers\topsecret (go up from temp.txt directory, up from answers, then to answers/topsecret). Option C: p1.relativize(p3) computes the path from /scratch/exam/topsecret/answers to /scratch/answers/topsecret, resulting in ..\..\.\answers\topsecret (up three levels from the nested path to reach the target). Option A is incorrect because p3.relativize(p1) reverses the direction. Option D is incorrect because the computation does not produce the target result. Option E and F are incorrect because they compute different relative paths.
Why the other options are wrong
- A. p3.relativize(p1) computes from /scratch/answers/topsecret to the nested path, producing the opposite direction.
- D. p3.relativize(p2) does not produce the required output path.
- E. p1.relativize(p2) computes a different relative path than required.
- F. p2.relativize(p1) computes the opposite direction from p1 to p2.
Question 9
Given the code fragment: public void foo(Function<Integer, String> fun) {...} Which two compile? (Choose two.)
Show answer and explanation
Correct answer: A, F. foo( n -> Integer.toHexString(n) ); foo( Integer::toHexString )
Option A compiles because n -> Integer.toHexString(n) is a valid lambda expression that takes an Integer parameter and returns a String. Option F compiles because Integer::toHexString is a valid method reference to a static method. Option B is invalid because toHexString without context is not a valid expression. Option C is invalid because the lambda returns an int (n + 1), but the Function requires a String return type. Option D is invalid because lambda parameters cannot have explicit type declarations like int when using arrow syntax. Option E is invalid because the lambda body n -> Integer::toHexString returns a method reference, not a String. Option G is invalid because n::toHexString is not valid syntax for method references. Option H is invalid because lambda parameters cannot use explicit type declarations like (int n) in this context.
Why the other options are wrong
- B. toHexString without context or qualification is not a valid expression.
- C. The lambda returns int, but Function<Integer, String> requires String return type.
- D. Lambda parameters cannot use explicit type declarations like int in arrow syntax.
- E. The lambda body returns a method reference, not a String.
- G. n::toHexString is not valid method reference syntax.
- H. Lambda parameters cannot use explicit type declarations like (int n).
Question 10
Which declaration of an annotation type is legal?
Show answer and explanation
Correct answer: A. @interface Author { String name() default “”; String date(); }
Option A is correct because it declares a valid annotation type with two methods: name() with a default value of empty string and date() as a required method. Annotation methods can have default values using the default keyword. Option B is incorrect because annotation types cannot extend any interface; they implicitly extend java.lang.annotation.Annotation. Option C is incorrect because default values cannot be null for any type. Option D is incorrect because date must be declared as a method with parentheses (date()), not as a field. Option E is incorrect because the syntax for default values is default followed by the value, not the reverse order.
Why the other options are wrong
- B. Annotation types cannot extend interfaces; they implicitly extend java.lang.annotation.Annotation.
- C. Default values in annotations cannot be null.
- D. Annotation members must be methods with parentheses, not fields; date must be date().
- E. The correct syntax for default values is default followed by the value, not the reverse.
Question 11
Given: public interface Builder { public A build(String str); } and Assuming that this code compiles correctly, which three statements are true? (Choose three.)
Show answer and explanation
Correct answer: B, C, E. A cannot be final; B cannot be abstract; B is a subtype of A.
In the BuilderImpl class, B is a concrete implementation that returns instances of type A through the build method. B cannot be abstract because it provides a concrete implementation of the build method. A cannot be final if it's meant to be extended or implemented by other classes in a typical Builder pattern, but more importantly, A can be abstract since the interface specifies it as a return type without restricting its modifiers. B is a subtype of A because BuilderImpl implements Builder, and through the build method's return type, B produces objects of type A, establishing a subtype relationship. A cannot be final when used as a return type in a builder pattern context, as it needs to support polymorphism and extension. E is correct: B is a subtype of A in the polymorphic sense where the builder returns instances of A. The interface contract allows A to be abstract, and B must be instantiable to fulfill the builder contract.
Why the other options are wrong
- A. A can be abstract; abstract types are valid return types in interfaces and are commonly used in builder patterns.
- D. B can be final; there is no constraint preventing the concrete builder implementation from being final.
- F. A is not a subtype of B; rather, B produces instances of A, making B a subtype of the Builder interface and A the return type.
Question 12
Assuming the user credentials are correct, which expression will create a Connection?
Show answer and explanation
Correct answer: B. DriverManager.getConnection("jdbc:derby:com")
Option B is correct because it uses the proper JDBC URL format with the jdbc: protocol scheme followed by the database subprotocol (derby in this case). The DriverManager.getConnection() method requires a properly formatted JDBC connection URL as its first parameter. Option A uses http:// which is not a valid JDBC protocol. Option C omits the jdbc: prefix required for JDBC URLs. Option D provides no connection URL. Option E omits the required connection URL parameter entirely.
Why the other options are wrong
- A. The http:// protocol is not valid for JDBC; JDBC URLs must use the jdbc: protocol prefix.
- C. Missing the jdbc: protocol prefix means this is not a valid JDBC connection URL.
- D. getConnection() requires at least a connection URL parameter; calling with no arguments will fail.
- E. The connection URL is missing entirely; credentials alone cannot create a connection.
Question 13
Given: public interface ExampleInterface{ } Which two statements are valid to be written in this interface? (Choose two.)
Show answer and explanation
Correct answer: A, E. public String methodD();; public abstract void methodB();
Option A is valid because abstract methods are implicitly public in interfaces. Option E is valid because it explicitly declares an abstract method with the public and abstract keywords, which is allowed. Option B is invalid because interfaces cannot contain instance variables. Option C is invalid because methods cannot have implementations with the final modifier in interfaces. Option D is invalid because it omits public. Option F is invalid because default method implementations require a version declaration. Option G is invalid because interface members cannot be private.
Why the other options are wrong
- B. Interfaces cannot declare instance variables; only constants are allowed.
- C. Interface methods cannot use the final modifier with method bodies in standard interface declarations.
- D. Methods in interfaces must be public, either explicitly or implicitly.
- F. Method implementations in interfaces require the default keyword and are only valid in modern Java versions with proper syntax.
- G. Interface members cannot be declared as private; they must be public or package-protected at minimum.
Question 14
You want to read data through the reader object. Which statement inserted on line 1 will accomplish this?
Show answer and explanation
Correct answer: D. reader.read(characters);
The FileReader.read(char[]) method reads characters from the file into the provided character array. Option D correctly passes the characters array to the reader.read() method, which populates the array with data read from the file. This is the standard way to read data from a FileReader into a pre-allocated character buffer.
Why the other options are wrong
- A. reader.read() without arguments returns a single character as an int, not filling the array; it doesn't assign to characters properly for bulk reading.
- B. readLine() returns a String representing a single line, not reading into the char array, and the return value is not used or assigned.
- C. Calling characters.read() attempts to invoke a method on the char array itself, which doesn't exist; arrays don't have a read() method.
Question 15
What is the result?
Show answer and explanation
Correct answer: A. 357
The code initializes i to 0 (implicitly), then enters a while loop that iterates through the primes array {2,3,5,7}. When i equals 3, the if condition (i == 3) is true, causing a break statement that exits the loop. Before the break, the loop appends primes[0]=2, primes[1]=3, and primes[2]=5 to the result string. The value at index 3 (which is 7) is never appended because the loop breaks when i reaches 3. Therefore, result contains "357".
Why the other options are wrong
- B. This would be the result if the break occurred after i==3 instead of at i==3, leaving out the element at index 2.
- C. This would require a different loop condition or initialization that doesn't match the code shown.
- D. This represents the entire array, but the break statement prevents the final element from being added to result.
- E. The loop condition (i < primes.length) and array accesses are valid, so no exception is thrown.
Question 16
A company has an existing Java 8 jar file, sales-app-1.1.1.jar, that uses several Apache open source jar files that have not been modularized. Which module-info.java file should be used to convert sales-app-1.1.jar to a module?
Show answer and explanation
Correct answer: B. module com.company.sales_app { requires org.apache.commons.beanutils; requires org.apache.commons.collections4; requires org.apache.commons.lang3; requires org.apache.commons.text; }
When converting non-modularized JAR files to modules, the module name in the requires directive must match the Automatic-Module-Name declared in the JAR's manifest, not the filename. The exhibit shows that commons-collections4-4.2.jar has Automatic-Module-Name: org.apache.commons.collections4, commons-lang3-3.8.1.jar has org.apache.commons.lang3, and commons-text-1.3.jar has org.apache.commons.text. Option B correctly uses org.apache.commons.beanutils (the standard module name for that library) and the three explicitly declared automatic module names, making it the proper module-info.java declaration.
Why the other options are wrong
- A. Uses 'commons.beanutils' instead of 'org.apache.commons.beanutils' and incorrectly strips the 'org.apache' prefix from the other modules that explicitly declare their full automatic module names.
- C. Removes the 'org.apache' namespace prefix from all module names, which does not match the automatic module names declared in the JAR manifests.
- D. Includes version numbers in the requires declarations, which is not valid syntax in module-info.java; module names must not contain version information.
Question 17
A company has an existing Java app that includes two Java 8 jar files, sales-8.10.jar and clients-10.2.jar. The jar file, sales-8.10.jar, references packages in clients-10.2.jar, but clients-10.2.jar does not reference packages in sales-8.10.jar. They have decided to modularize clients-10.2. jar. Which module-info.java file would work for the new library version clients-10.3.jar?
Show answer and explanation
Correct answer: D. module com.company.clients { exports com.company.clients; }
Option D is correct because the clients-10.2.jar only exports its packages and does not require any other modules (sales-8.10.jar depends on clients, not the reverse). The module-info.java should declare exports for the packages that sales-8.10.jar needs to access. Option A is invalid because a module cannot require itself. Option B is invalid because uses is for service consumption, not for exposing packages. Option C is more restrictive, exporting only a specific class rather than the package.
Why the other options are wrong
- A. A module cannot have a requires clause referencing itself; this is not valid.
- B. The uses keyword is for service interfaces, not for making packages available to dependent modules.
- C. While technically valid, exporting only a specific class is unnecessarily restrictive compared to exporting the entire package.
Question 18
Which two var declarations are correct? (Choose two.)
Show answer and explanation
Correct answer: A, C. var names = new ArrayList<>();; var var = “hello”;
Option A is correct because var names = new ArrayList<>(); properly initializes a variable with an inferred type from the ArrayList constructor, providing sufficient type information for the compiler. Option C is correct because var var = "hello"; is a valid declaration where var (as a reserved type name) can be used as a variable identifier, and the type is inferred as String from the initializer. Option B fails because underscores alone cannot be used as variable identifiers in Java (underscore-only names are reserved). Option D fails because var d = null; lacks sufficient type information, null has no type, so the compiler cannot infer the variable's type. Option E fails because var a; lacks an initializer, providing no type information for inference, which violates the requirement that var declarations must include an initializing expression.
Why the other options are wrong
- B. Underscore (_) alone is a reserved identifier in Java and cannot be used as a variable name.
- D. The initializer null provides no type information, making type inference impossible.
- E. The var declaration requires an initializer; a declaration without an assignment has no type to infer.
Question 19
Which two statements are correct about modules in Java? (Choose two.)
Show answer and explanation
Correct answer: D, E. A module must be declared in module-info.java file,; java.base exports all of the Java platforms core packages.
Option D is correct because a module must be declared in a module-info.java file; this is a requirement of the module system. Option E is correct because java.base automatically exports all of the Java platform's core packages, making them available to all other modules. Option A is incorrect because module-info.java can be empty. Option B is incorrect because module-info.java must be placed at the root of the module source directory, not in any arbitrary folder. Option C is incorrect because modules do not automatically have access to each other; explicit requires declarations are necessary.
Why the other options are wrong
- A. An empty module-info.java file is valid and creates an unnamed module.
- B. module-info.java must be located at the root of the module directory, not in arbitrary folders.
- C. Modules in the same folder do not automatically access each other; explicit module declarations and requires clauses are necessary.
Question 20
Given the code fragment: Integer i = 11; Which two statements compile? (Choose two.)
Show answer and explanation
Correct answer: A, B. Double c = (Double) i;; Double b = Double.valueOf(i);
Option A is valid because explicit casting can convert an Integer reference to a Double reference at compile time (though it would fail at runtime, it compiles). Option B is valid because Double.valueOf() can accept an Integer argument and returns a Double object through autoboxing and conversion. Option C is invalid because there is no automatic conversion from Integer to Double. Option D is invalid because parseDouble() expects a String, not an Integer. Option E is invalid because there is no automatic unboxing conversion from Integer to double primitive.
Why the other options are wrong
- C. There is no implicit conversion from Integer to Double; they are different wrapper types.
- D. Double.parseDouble() requires a String argument, not an Integer.
- E. Integer cannot be automatically unboxed to a double primitive; Integer unboxes to int, not double.
Question 21
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.)
Show answer and explanation
Correct answer: A, D. @Resource({“Customer1”, “Customer2”}); @Resource(“Customer1”)
Option A is valid because an array of strings can be passed as the value. Option D is valid because when the annotation contains a single-element array called value(), a single string can be passed directly without array braces. Option B is invalid (empty nested braces), C requires the value parameter to be specified, and E is invalid because value() requires at least one element.
Why the other options are wrong
- B. Empty braces {{}} are not valid syntax for array initialization in annotation values.
- C. The value() element is required and cannot be omitted; the annotation must provide a value.
- E. The empty parentheses provide no value for the required value() parameter.
Question 22
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.)
Show answer and explanation
Correct answer: B, D. .map(testName::compareToIgnoreCase); .peek(Member::print)
Method references in Java streams must reference actual methods that can be invoked on the stream elements. Option B uses testName::compareToIgnoreCase, which correctly references the compareToIgnoreCase method on the String object testName, allowing it to be called on each Member's name through map(). Option D uses Member::print, which correctly references the instance method print() defined in the Member class, allowing peek() to call it on each Member in the stream. Both are valid method reference syntaxes that can replace lambda expressions in their respective stream operations.
Why the other options are wrong
- A. Integer::equals(0) is invalid syntax; method references cannot include parameters in parentheses, and equals is not a static method suited for this use.
- C. Member::getYearsMembership() is invalid because method references cannot include method invocation parentheses or comparison operators; the comparison >= cannot be part of a method reference.
Question 23
Which module defines the foundational APIs of the Java SE Platform?
Show answer and explanation
Correct answer: A. java.base
The java.base module defines the foundational APIs of the Java SE Platform, including essential packages like java.lang, java.util, and java.io. It is the base module that all other modules implicitly depend on and cannot be removed from any Java runtime.
Why the other options are wrong
- B. java.se is an aggregator module that depends on other modules but does not define the foundational APIs itself.
- C. java.lang is a package, not a module, and is contained within the java.base module.
- D. java.object does not exist as a standard Java module.
Question 24
Given the code fragment: You must make the count variable thread safe. Which two modifications meet your requirement? (Choose two.)
Show answer and explanation
Correct answer: C, D. replace line 3 with synchronized(test) { test.count++; }; replace line 1 with private AtomicInteger count = new AtomicInteger(0); and replace line 3 with test.count.incrementAndGet();
To make the count variable thread-safe in a multi-threaded environment where 10 tasks each increment count 10,000 times, you need to protect access to the shared variable. Option C uses synchronized block with test as the lock object, ensuring that only one thread can execute test.count++ at a time, preventing race conditions. Option D replaces the primitive int with AtomicInteger, which provides atomic operations through incrementAndGet(), eliminating the need for explicit synchronization while guaranteeing thread-safe increments. Both approaches effectively prevent concurrent modification issues that would otherwise result in lost updates.
Why the other options are wrong
- A. Synchronizing the main method doesn't protect the count variable from concurrent access by the 10 submitted tasks that execute in parallel.
- B. The volatile keyword ensures visibility of changes across threads but does not prevent race conditions on compound operations like count++, which involves read-modify-write that can be interrupted.
- E. You cannot synchronize on test.count when it is a primitive int; primitives cannot be used as lock objects in Java.
Question 25
and What is the output?
Show answer and explanation
Correct answer: C. Hello world! Bonjour le monde!
The Bar class extends Foo and overrides the foo() method with a signature that takes a List parameter instead of Collection. In main(), b.foo(li) calls the overridden method in Bar (taking List), printing "Hello world!". Then b.foo(co) calls the foo() method where co is a Collection reference; since Bar's foo() method only overrides the Collection version from Foo (the parameter types don't match exactly for the List version), this resolves to Foo's foo(Collection) method, printing "Bonjour le monde!". The output is "Hello world!" followed by "Bonjour le monde!".
Why the other options are wrong
- A. This would require both calls to invoke Foo's method, but the first call b.foo(li) matches Bar's more specific List parameter signature.
- B. This would require both calls to invoke Bar's method, but b.foo(co) uses a Collection reference that doesn't match Bar's List parameter and falls back to Foo's method.
- D. This reverses the order; the first call invokes Bar's foo(List) which prints "Hello world!", not Foo's method.
Question 26
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?
Show answer and explanation
Correct answer: D. You reject the change because -noverify is a critical security risk.
The -noverify flag disables bytecode verification in the JVM, which is a critical security mechanism that validates bytecode before execution. Disabling this opens the application to malicious or corrupted code that could compromise system integrity. This change should be rejected as it introduces an unacceptable security vulnerability.
Why the other options are wrong
- A. -noverify is not necessary for modern Java versions and is discouraged for security reasons.
- B. The memory settings -Xms8g -Xmx8g are reasonable for server applications and not the primary concern.
- C. -noverify has been deprecated and removed from recent Java versions, and more importantly, disabling verification is a security risk regardless of support history.
Question 27
Given the content from lines.txt: C C++ Java Go Kotlin and What is the result?
Show answer and explanation
Correct answer: A. C C++ Go Kotlin
The code reads lines from lines.txt, filters to keep only lines that do NOT contain "JAVA" (case-insensitive), converts remaining lines to uppercase, and collects them into a list. Given the input "C C++ Java Go Kotlin", the filter removes "Java", leaving "C", "C++", "Go", and "Kotlin". These are then converted to uppercase and printed, producing "C C++ GO KOTLIN".
Why the other options are wrong
- B. This output shows only "JAVA", which is actually filtered out and removed by the negated filter condition (!line.equalsIgnoreCase("JAVA")).
- C. While this correctly shows the uppercase conversion, it's missing "C++" which should be included since it doesn't match the filter condition.
- D. This includes "JAVA" in the output, but the filter explicitly removes any line containing "JAVA" (case-insensitive), so "JAVA" should not appear in the result.
That was 27 of 213.
The full Oracle 1Z0-819 pack has all 213 questions, each with the answer, the explanation and why the other options are wrong, plus a questions-only copy for timed runs. US$39, paid once, with free monthly updates and a pass-or-your-money-back guarantee.
Not ready yet? Get the first 96 free as one PDF by email. Get the Half Pack →
