Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 00h 00m 00s Coupon code: 50OFF
Welcome to QA4Exam

Free practice questions with explanations

Oracle 1Z0-819 Dumps 2026 with Free Practice Questions and Answers

Practise for the Java SE 11 Developer exam with 18 original questions, each with an answer and explanation.

Topics: Java Object-Oriented Approach, Concurrency, Java I/O API, Java Platform Module System and 9 more.

Includes single answer, dropdown, multiple answers, order list and drag and drop. A new question is added every 15 days.

1Z0-819 Practice Set Details

Vendor
Oracle
Exam Code
1Z0-819
Questions On This Page
18
Exam Topics Covered
13 of 13
Question Types
5
Newest Question
New Question
Every 15 days
Full Question Set
296
Certification
Oracle Java
18 questions

Oracle 1Z0-819 Exam Questions and Answers by Topic

Working with Java Data Types

1 practice question on this topicWhat this topic covers

Question 1

Added

Single Answer

A telemetry parser receives decimal digits in a String and must compute their sum without overflowing an int. The input can contain up to 100,000 digits. A team member proposes accumulating by repeatedly concatenating each digit to a StringBuilder and then parsing the result as a long, but the result may exceed long as well. Which implementation best meets the stated need to return the exact sum as an int?

Correct answer: D

Each character can be converted to its numeric digit by subtracting '0', and summing digit values avoids constructing or parsing the potentially enormous represented number. Math.addExact makes overflow explicit if the exact sum cannot fit the required int return type. Integer.parseInt fails when the whole decimal value exceeds int range, and a long has the same fundamental issue for sufficiently long input. Casting a long sum silently truncates when the sum is outside int range.

Controlling Program Flow

1 practice question on this topicWhat this topic covers

Question 2

Added

Single Answer

A command-line tool accepts a status code represented by an int. Codes 10 and 11 should produce the same message; code 12 should produce a different message; every other value should produce an error message. The tool must compile on Java 11, and each branch must stop before the next branch's actions execute. Which switch fragment is valid and meets the behavior?

Correct answer: D

Java 11 supports traditional colon-style switch labels, so consecutive case 10 and case 11 labels share the same body. The breaks prevent execution from falling through to later actions. Comma-separated labels in a case are not supported by Java 11's switch statement syntax. The fragment with no breaks falls through and prints multiple messages. The final fragment falls through from the active cases into the pending action.

Java Object-Oriented Approach

3 practice questions on this topicWhat this topic covers

Question 3

Added

Single Answer

A monitoring library has an abstract class Sensor with a protected constructor and an abstract method reading(). Two concrete sensor classes extend Sensor. A deployment team wants to create sensor implementations without modifying the library, while ensuring every implementation can be referenced uniformly and that callers can instantiate only concrete sensor types. Which declaration best satisfies these requirements?

Correct answer: B

An abstract superclass can define the shared contract and prevent direct instantiation, while concrete subclasses implement reading() and can be assigned to Sensor references. The protected constructor also permits subclass construction without exposing it as a general public construction API. A concrete class with a null-returning method does not enforce implementation. A final class cannot be subclassed, and a class with an abstract method cannot be concrete. An interface cannot declare a constructor, protected or otherwise.

Question 4

Added

Single Answer

A library exposes an immutable Customer record-like class in Java 11. Its instances must safely retain the supplied list of tags, callers must not mutate the stored tags through either the constructor argument or an accessor, and the class cannot use records because the project targets Java 11. Which design best meets these requirements?

Correct answer: B

A defensive copy on construction prevents later changes to the caller's list from altering the Customer. Returning another copy prevents callers from changing the stored collection, even through a mutable list reference. A directly stored list remains externally mutable. An unmodifiable view blocks mutation through that view but does not protect the field from changes through the original constructor argument. A static field would incorrectly share tags across all instances.

Question 5

Added

Single Answer

A framework defines an interface with one abstract method, a default method, a static factory method, and a private helper used by the default method. A client wants to create an instance inline using a lambda while retaining the default behavior and factory API. The code must compile under Java 11. Which statement is correct?

Correct answer: C

A functional interface has one abstract method, and its default, static, and private methods do not increase that count. Java 11 permits private interface methods, which can support implementation reuse within the interface; a lambda supplies the abstract method while the other methods remain available according to their invocation rules. Counting all methods as abstract incorrectly excludes the interface. Changing the helper or removing the factory is unnecessary and would not be required for lambda compatibility.

Exception Handling

1 practice question on this topicWhat this topic covers

Question 6

Added

Order List

A batch importer reads a file with try-with-resources and may throw IOException while parsing records. Its caller must receive a domain-specific ImportException whose cause is the original IOException, and the file must be closed before the wrapped exception leaves the method. Arrange the implementation steps in the order they must occur.

Drag the steps into the correct order, or use the arrows.

  1. Read and parse records inside the try block
  2. Catch IOException after the try-with-resources block
  3. Construct and throw ImportException with the caught exception as cause
  4. Open the input using a try-with-resources declaration
Correct answer:
  1. Open the input using a try-with-resources declaration
  2. Read and parse records inside the try block
  3. Catch IOException after the try-with-resources block
  4. Construct and throw ImportException with the caught exception as cause

The resource is initialized before parsing begins, and try-with-resources closes it when control exits the try block, including when an IOException occurs. The catch then receives that exception after resource closure and can preserve it as the cause of the domain-specific exception. Catching and wrapping before leaving the try body is not the structure described, and throwing a wrapper without the original cause would lose diagnostic information.

Working with Arrays and Collections

1 practice question on this topicWhat this topic covers

Question 7

Added

Multiple Answers

A scheduling component receives a List of Jobs and must return the jobs ordered by descending priority, with ties ordered by ascending submission time. The input list must remain unchanged, and the returned list must be mutable because a later stage removes jobs from it. Job does not implement Comparable. Which two actions together satisfy the requirements? (Choose two.)

Correct answer: D, E

Copying into an ArrayList preserves the source list and produces a mutable result. A comparator can express both sort keys: reverse the priority comparison and then compare submission time normally, ensuring deterministic tie ordering. Sorting the original violates the nonmutation requirement and the priority-only comparator omits the tie-breaker. Converting to a Set can discard duplicates and does not provide the required ordering. List.copyOf returns an unmodifiable list, so it cannot be sorted in place.

Working with Streams and Lambda Expressions

1 practice question on this topicWhat this topic covers

Question 8

Added

Multiple Answers

A service processes a large collection of transactions. It must produce a Map partitioned by whether each transaction is refundable, and each partition must preserve encounter order from the source. The source is an ordered List, and correctness is more important than speculative parallel speedup. Which two choices meet these requirements? (Choose two.)

Correct answer: B, D

A sequential stream over the ordered List combined with partitioningBy produces the required Boolean-keyed partitions while retaining the stream's encounter order within each downstream list. The predicate defines which transactions enter the true partition. groupingBy produces a general classification map but does not directly guarantee the required two-key partitioning result. toMap cannot store multiple transactions per Boolean key without a merge strategy and a list-valued mapping. An unordered parallel stream discards the encounter-order guarantee.

Java Platform Module System

2 practice questions on this topicWhat this topic covers

Question 9

Added

Drag And Drop

A Java 11 modular application uses a provider module and a consumer module. The provider defines a service interface and an implementation, while the consumer discovers implementations through ServiceLoader. The provider implementation package should not be generally accessible to other modules. Match each module declaration requirement to the directive that supplies it.

Drag each item onto its matching target. On a phone: tap an item, then tap a target.

Provider module registers an implementation for discovery
Provider module makes the service API available to consumers
Consumer module declares dependence on the provider module
Consumer module declares service discovery dependency
uses service.api.Service
requires provider.module
exports service.api
provides service.api.Service with internal.ServiceImpl
Correct answer:
  • Provider module makes the service API available to consumers → exports service.api
  • Provider module registers an implementation for discovery → provides service.api.Service with internal.ServiceImpl
  • Consumer module declares dependence on the provider module → requires provider.module
  • Consumer module declares service discovery dependency → uses service.api.Service

A module exports the package containing the API so another module can use its public types. The provider's provides directive registers the implementation for the service type without exporting the implementation package. The consumer needs a requires directive for the module that supplies the service, and uses declares its intention to locate implementations through ServiceLoader. Exporting the internal implementation package would expose more than required, while omitting the service directives prevents proper service declaration and discovery.

Question 10

Added

Single Answer

A team distributes a Java 11 command-line application as a modular JAR and wants to launch it directly with the module launcher. The application has a module-info.java that declares its dependencies and exports, and its main class is in the named module. Which command form explicitly launches that main class as part of the named module from a module path?

Correct answer: B

The --module-path option supplies modular artifacts, and -m selects a module and its main class using the module/class form. This launches the entry point in the named module and uses its descriptor for module resolution. The class-path form treats the application as part of the unnamed module. --class-path does not establish a module path, and -jar does not accept the shown option as a way to select a named module.

Concurrency

2 practice questions on this topicWhat this topic covers

Question 11

Added

Single Answer

A reporting service submits independent calculations to an ExecutorService. Each calculation can fail with a checked exception, and the caller must retrieve each result and observe that failure without wrapping the calculation in a custom thread class. The service must wait for all submitted calculations before returning, but it must not shut down the shared executor because other components use it. Which approach best satisfies these constraints?

Correct answer: D

Callable supports a return value and a checked exception, while Future.get both waits for completion and reports task failure through ExecutionException. Retaining all futures lets the caller wait for all tasks without taking ownership of the shared executor. A Runnable has no result and cannot declare a checked exception from run. Direct execution loses the required concurrent submission. Shutting down the shared executor would disrupt its other users.

Question 12

Added

Order List

A thread-safe cache stores values in a HashMap and uses a ReentrantReadWriteLock. A read operation must access the map under the read lock, and a write operation must access it under the write lock. The lock must always be released even if map access or value computation throws. Arrange the actions for a write operation in the correct order.

Drag the steps into the correct order, or use the arrows.

  1. Perform the map update inside a try block
  2. Call unlock in the finally block
  3. Call lock on the write Lock
  4. Obtain the write Lock from the ReentrantReadWriteLock
Correct answer:
  1. Obtain the write Lock from the ReentrantReadWriteLock
  2. Call lock on the write Lock
  3. Perform the map update inside a try block
  4. Call unlock in the finally block

The write lock object is selected first and acquired before accessing the non-thread-safe HashMap. The update belongs inside the protected region. Placing unlock in finally ensures release whether the update completes normally or throws, preventing other threads from being blocked indefinitely. Unlocking before the update would leave the map unprotected, while acquiring a read lock would not provide exclusive access for mutation.

Java I/O API

2 practice questions on this topicWhat this topic covers

Question 13

Added

Single Answer

A deployment utility must copy a directory tree containing nested directories and symbolic links. It must preserve file attributes where supported, avoid following symbolic links during traversal, and report copy failures to its caller. The utility runs on Java 11 and should use the NIO file-system API rather than hand-written recursion. Which approach best meets these requirements?

Correct answer: D

Files.walkFileTree traverses nested directories through a FileVisitor, and without FOLLOW_LINKS it does not follow symbolic links. Files.copy can request COPY_ATTRIBUTES, which preserves attributes where supported; its failures can propagate from the visitor or be reported through traversal exceptions. FOLLOW_LINKS contradicts the traversal requirement. Files.list is not recursive and REPLACE_EXISTING does not preserve requested attributes. Object serialization is not a file-tree copy mechanism.

Question 14

Added

Dropdown

A Java 11 program writes a sequence of Serializable objects to a file and later reads them back in the same order. The file should be truncated when a new export begins, and the streams should close even if serialization fails. Complete the declarations with the appropriate stream classes and file-opening option.

Choose the correct value for each blank.

try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(path, ))) { out.writeObject(value); } ObjectInputStream in = new ObjectInputStream(Files.(path));
Correct answer:

try (ObjectOutputStream out = new ObjectOutputStream(Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING))) { out.writeObject(value); } ObjectInputStream in = new ObjectInputStream(Files.newInputStream(path));

CREATE ensures the output file is created when absent, and TRUNCATE_EXISTING removes prior contents so the new object stream begins as a fresh serialization stream. ObjectOutputStream and ObjectInputStream provide the matching object serialization and deserialization formats. APPEND can leave an existing stream header and contents that are not a fresh stream. The other option combinations do not provide the required output behavior. Files.newInputStream is the appropriate input factory; newOutputStream, readAllBytes, and lines do not create an object input stream.

Secure Coding in Java SE Application

1 practice question on this topicWhat this topic covers

Question 15

Added

Single Answer

An application accepts a filename from an authenticated user and must read it from a designated storage directory. Users must not escape that directory with absolute paths or parent-directory segments. Symbolic links may be present in the storage tree, but the application must not read a file reached through a link that resolves outside the directory. Which validation approach is the most appropriate before opening the file?

Correct answer: D

Normalization and a startsWith check prevent ordinary absolute-path and parent-segment escapes, while comparing real paths addresses symbolic links that resolve outside the permitted root. The real storage root should likewise be used as the containment boundary. Rejecting a substring is both incomplete and overly restrictive, and it does not defend against links. Taking only a basename changes the intended path and uses the working directory. Canonicalizing without comparing against the allowed root performs no authorization check.

Database Applications with JDBC

1 practice question on this topicWhat this topic covers

Question 16

Added

Single Answer

A service queries a table using a user-supplied account identifier. The database driver supports prepared statements, and the query must return only the matching account while preventing the identifier from being interpreted as SQL syntax. The service also needs to process the result and release database resources even if processing fails. Which implementation is the best fit?

Correct answer: A

A PreparedStatement parameter keeps the supplied value separate from SQL syntax, preventing injection through the identifier while allowing the database to execute the intended predicate. Try-with-resources closes AutoCloseable JDBC resources on normal and exceptional paths; the result set can also be managed in its own resource declaration. Manual quote escaping is error-prone and does not match the required parameterization. A Statement concatenation remains injectable. CallableStatement and garbage-collection cleanup do not address the stated needs.

Localization

1 practice question on this topicWhat this topic covers

Question 17

Added

Dropdown

A reporting application formats monetary totals for the user's requested locale. It must use localized currency conventions and parse a localized amount from a complete input string, rejecting any unconsumed trailing characters. Complete the code by selecting the correct API calls for the blanks.

Choose the correct value for each blank.

NumberFormat nf = NumberFormat.(locale); ParsePosition pos = new ParsePosition(0); Number value = nf.(input, pos); if (value == null || pos.getIndex() != input.length()) reject();
Correct answer:

NumberFormat nf = NumberFormat.getCurrencyInstance(locale); ParsePosition pos = new ParsePosition(0); Number value = nf.parse(input, pos); if (value == null || pos.getIndex() != input.length()) reject();

getCurrencyInstance(Locale) selects a NumberFormat configured for localized monetary values. The ParsePosition overload of parse returns the parsed Number and advances the position; checking the final index rejects input with unconsumed trailing text. getIntegerInstance and getPercentInstance apply different formatting conventions, while generic getInstance is not the explicit currency formatter requested. format produces text rather than parsing, parseObject is not the relevant NumberFormat API here, and parseCurrency does not exist.

Annotations

1 practice question on this topicWhat this topic covers

Question 18

Added

Single Answer

A payments team uses a runtime annotation to mark service methods that require an audit record. The annotation must be available to a reflective interceptor, apply only to methods, and be inherited when a subclass overrides the annotated method only if the override is itself annotated. The team wants to prevent accidental use on fields or types. Which declaration best meets these requirements?

Correct answer: A

Runtime retention makes the annotation visible to the interceptor, and the method-only target prevents its use on fields or types. @Inherited applies only to class annotations, not method annotations, so including it cannot provide the stated method inheritance behavior and is unnecessary. CLASS retention is not available through runtime reflection. Allowing TYPE as a target violates the restriction against annotating types.

More Oracle Practice Questions

Get the Full Oracle 1Z0-819 Dumps as PDF and Practice Test

18 questions are free on this page and the full set has 296. It comes as a PDF and an online practice test, with 90 days of free updates.