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-809 Dumps 2026 with Free Practice Questions and Answers

Practise for the Java SE 8 Programmer II exam with 15 original questions, each with an answer and explanation.

Topics: Exceptions And Assertions, Java Class Design, Java Concurrency, Advanced Java Class Design and 8 more.

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

1Z0-809 Practice Set Details

Vendor
Oracle
Exam Code
1Z0-809
Questions On This Page
15
Exam Topics Covered
12 of 12
Question Types
5
Newest Question
New Question
Every 15 days
Full Question Set
208
Certification
Oracle Java
15 questions

Oracle 1Z0-809 Exam Questions and Answers by Topic

Java Class Design

2 practice questions on this topicWhat this topic covers

Question 1

Added

Single Answer

A billing application needs an immutable `InvoiceKey` used as a key in hash-based maps. It contains a customer identifier and a list of line identifiers. Callers may pass a mutable list and later mutate it, and the accessor must not let callers alter the key after construction. Equality and hash code must reflect the identifier and the list contents. Which implementation strategy is safest?

Correct answer: C

A final class with private final state and a defensive copy prevents subclassing and stops later changes to the caller's input from changing the key. Returning an unmodifiable view prevents mutation through the accessor, while value-based `equals` and `hashCode` must use the same identity components for correct hash-map behavior. Storing or returning the mutable list exposes the key to mutation. Implementing equality without a corresponding hash code violates the general contract. A static list is shared across invoices and cannot represent per-instance state.

Question 2

Added

Multiple Answers

A document service exposes a mutable `Document` whose state is read by many threads. Each document has a unique identifier, and two instances with the same identifier must be considered equal even if their titles differ. The service also logs documents, and the log representation must show the identifier but not confidential title text. Choose the two implementation decisions that satisfy these requirements without relying on callers to synchronize access. (Choose two.)

Correct answer: A, D

Using the unique identifier consistently in `equals` and `hashCode` preserves the contracts required by hash-based collections and matches the stated identity rule. A `toString` implementation can safely provide the identifier for diagnostics while excluding confidential title data. Marking the title volatile does not make it the identity field and does not make compound state access generally thread-safe. Inheriting `Object.hashCode` when equality is identifier-based can give equal objects different hash codes. Synchronizing only `toString` does not protect other reads or writes.

Advanced Java Class Design

1 practice question on this topicWhat this topic covers

Question 3

Added

Single Answer

A scheduling library exposes an abstract `Job` type. Each job has a final `run()` method that performs auditing and then calls an overridable `execute()` method. A plug-in must supply `execute()`. A developer proposes an anonymous subclass at the call site, but the framework must also retain a strongly typed class object for reflective configuration and instantiate the plug-in repeatedly. The plug-in should not be instantiable except through the framework, and no auditing code may be overridden. Which design best meets these requirements?

Correct answer: A

A static nested subclass has a stable, nameable class type without requiring an enclosing framework instance. Its private constructor restricts direct creation, while the framework can instantiate it from an authorized context; implementing `execute()` supplies the required plug-in behavior and the final `run()` remains protected from overriding. A non-static named nested class requires an enclosing instance. A local class is scoped to a method and is unsuitable for retaining a class type for reflective configuration. Overriding `run()` is illegal because it is final.

Generics and Collections

1 practice question on this topicWhat this topic covers

Question 4

Added

Single Answer

A service stores `Task` objects in a `TreeSet` so that iteration is ordered by deadline and tasks with the same deadline remain distinct when their IDs differ. `Task` already implements `Comparable` by ID for use elsewhere, and that natural ordering must not be changed. The set must use a reusable ordering policy and must not violate the sorted-set contract by comparing distinct tasks as equal. Which approach is best?

Correct answer: A

A `TreeSet` uses its comparator, or the elements' natural ordering, to determine both ordering and whether elements are duplicates. Ordering first by deadline and then by ID provides the requested presentation while distinguishing tasks sharing a deadline. The comparator is reusable and leaves `Task`'s natural ordering unchanged. Overriding equality does not control `TreeSet` uniqueness. An `ArrayList` neither rejects duplicates nor maintains set semantics. A deadline-only comparator treats two tasks with the same deadline as equal for this set, so one would be lost.

Lambda Built-In Functional Interfaces

1 practice question on this topicWhat this topic covers

Question 5

Added

Single Answer

A pricing component accepts a transformation that takes one `BigDecimal` and returns a `BigDecimal`. The transformation is applied repeatedly to values, and callers must be able to compose transformations with the built-in operation that applies one unary transformation after another. The API should avoid defining a custom functional interface. Which parameter type is the best fit?

Correct answer: A

`UnaryOperator` is the specialization of `Function` for a single input and same-type result. It provides the unary composition operations needed by the pricing pipeline while expressing the signature directly. `Function` can accept the transformation but does not communicate the specialized contract as precisely. `BiFunction` requires two inputs, and `Consumer` returns no result.

Java Stream API

1 practice question on this topicWhat this topic covers

Question 6

Added

Single Answer

An analytics job receives a stream of transactions and must produce the first transaction, in encounter order, whose amount exceeds a threshold. No transaction may be assumed to exist, and downstream code must not receive a null sentinel. The stream may be backed by a one-shot source, so it cannot be traversed again after the search. Which implementation best meets these requirements?

Correct answer: B

Filtering retains only matching transactions, and `findFirst()` returns an `Optional` that represents either the first match in encounter order or absence without a null sentinel. `peek` is for observing elements, not filtering them, and `findAny` does not promise the first encounter-order match. Mapping nonmatches to null can cause a null-related failure in stream terminal operations and does not express the selection cleanly. Collecting and indexing fails when there are no matches and needlessly consumes the whole stream.

Exceptions and Assertions

2 practice questions on this topicWhat this topic covers

Question 7

Added

Single Answer

A configuration loader accepts a system property that selects a numeric retry limit. During development, the team wants an assertion to catch an invalid internal default, but malformed user-supplied values must produce a checked `ConfigurationException` in every deployment, including when assertions are disabled. The property may be absent, in which case the default is used. Which implementation best meets these requirements?

Correct answer: A

User input must be validated with ordinary control flow because assertions may be disabled at runtime; invalid text should therefore be converted to the required checked exception rather than relying on an `AssertionError`. An assertion is suitable for checking the positive internal invariant after the configured or default value has been selected. Converting an `AssertionError` to a checked exception makes required behavior depend on assertion enablement. Asserting that the property exists rejects the allowed absent-property case. Catching `NumberFormatException` but reporting the input error only with an assertion also fails when assertions are disabled.

Question 8

Added

Order List

A migration utility must copy a file while ensuring both streams close if reading or writing fails. If the copy operation itself fails, it should throw a custom checked exception that retains the original cause. The custom exception must be constructed only after the I/O failure is caught. Arrange the implementation steps in the order they must be performed.

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

  1. Catch the I/O exception after automatic resource closure.
  2. Throw the custom checked exception with the caught exception as its cause.
  3. Open the input and output streams in a try-with-resources statement.
  4. Perform the copy operation inside the resource scope.
Correct answer:
  1. Open the input and output streams in a try-with-resources statement.
  2. Perform the copy operation inside the resource scope.
  3. Catch the I/O exception after automatic resource closure.
  4. Throw the custom checked exception with the caught exception as its cause.

The streams are acquired within try-with-resources, so Java closes them as the scope exits whether copying succeeds or throws. The `catch` runs after that cleanup and can then translate the `IOException` into the application-specific checked exception while preserving diagnostic information as the cause. Catching outside the resource scope avoids manual close paths. Throwing the custom exception before the copy has failed would not represent the actual operation result.

Use Java SE 8 Date/Time API

1 practice question on this topicWhat this topic covers

Question 9

Added

Dropdown

A booking is entered as a local date and time in a named region. The application must convert it to an instant using that region's time-zone rules, including daylight-saving behavior, rather than assuming a fixed UTC offset. Complete the expression.

Choose the correct value for each blank.

Instant departure = LocalDateTime.of(date, time).atZone().toInstant();
Correct answer:

Instant departure = LocalDateTime.of(date, time).atZone(zoneId).toInstant();

`LocalDateTime.atZone(ZoneId)` applies the time-zone rules for the named region, including applicable daylight-saving transitions, and `toInstant()` obtains the corresponding timeline point. `ZoneOffset.UTC` forces UTC and ignores the booking's named region. A `Duration` and a `Period` represent amounts of time, not a time zone, so neither can supply the required regional rules.

Java I/O Fundamentals

1 practice question on this topicWhat this topic covers

Question 10

Added

Dropdown

A command-line tool reads UTF-8 text from a file and writes the processed text to another file. The team wants character-oriented buffered I/O and explicit encoding, rather than byte streams or the platform default charset. Complete the resource declarations.

Choose the correct value for each blank.

try (BufferedReader in = Files.newBufferedReader(inputPath, ); BufferedWriter out = Files.newBufferedWriter(outputPath, )) { ... }
Correct answer:

try (BufferedReader in = Files.newBufferedReader(inputPath, StandardCharsets.UTF_8); BufferedWriter out = Files.newBufferedWriter(outputPath, StandardCharsets.UTF_8)) { ... }

`Files.newBufferedReader` and `Files.newBufferedWriter` accept a `Charset`, so `StandardCharsets.UTF_8` applies the required encoding consistently in both directions and avoids dependence on the host's default. The default charset can differ between deployments. US-ASCII cannot represent general UTF-8 content, and ISO-8859-1 is a different encoding with different byte mappings.

Java File I/O (NIO.2)

1 practice question on this topicWhat this topic covers

Question 11

Added

Drag And Drop

A deployment tool uses NIO.2 paths to inspect a release directory. It must distinguish a missing path from a regular file, read matching configuration files as a stream of lines, and move an obsolete file to an archive path. Select the appropriate API for each operation.

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

Determine whether a path is a regular file
Determine whether a path exists
Read file lines as a stream
Move a path to an archive path
Files.isRegularFile(Path, LinkOption...)
Files.exists(Path, LinkOption...)
Files.lines(Path, Charset)
Files.move(Path, Path, CopyOption...)
Correct answer:
  • Determine whether a path exists → Files.exists(Path, LinkOption...)
  • Determine whether a path is a regular file → Files.isRegularFile(Path, LinkOption...)
  • Read file lines as a stream → Files.lines(Path, Charset)
  • Move a path to an archive path → Files.move(Path, Path, CopyOption...)

The NIO.2 `Files` methods correspond directly to these path operations: `exists` checks presence, `isRegularFile` checks the file type, `lines` supplies a lazily consumed stream of lines, and `move` relocates a path with optional copy options. Using `Files.readAllLines` would materialize all lines rather than provide the required stream. A `Path` method alone does not perform the requested filesystem checks or move.

Java Concurrency

2 practice questions on this topicWhat this topic covers

Question 12

Added

Single Answer

A monitoring service runs many independent tasks through an `ExecutorService`. Each task increments a shared `long` counter, and the final count must equal the number of completed increments. The counter is updated frequently, but no compound operation beyond increment is needed; tasks do not need to block one another, and contention makes a single synchronized critical section undesirable. Which change provides the required correctness with the least coordination?

Correct answer: C

`AtomicLong.incrementAndGet()` performs the increment as an atomic read-modify-write operation, so concurrent updates are not lost without serializing each task's whole execution. A plain increment is a compound operation and can race. `volatile` provides visibility and ordering for individual accesses but does not make `counter++` atomic. Synchronizing on each task instance does not protect the shared counter because different tasks use different locks.

Question 13

Added

Order List

A parallel computation is implemented with the Fork/Join framework. Each task either computes a small range directly or splits a larger range into two subtasks and combines their results. To avoid unnecessary scheduling overhead and to return the combined result correctly, arrange the core actions in the required order for the recursive case.

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

  1. Fork one subtask and compute the other subtask.
  2. Join the forked subtask and combine both results.
  3. Split the range into two smaller ranges.
  4. Check whether the range is small enough for direct computation.
Correct answer:
  1. Check whether the range is small enough for direct computation.
  2. Split the range into two smaller ranges.
  3. Fork one subtask and compute the other subtask.
  4. Join the forked subtask and combine both results.

A Fork/Join task first checks its threshold so small work can be computed directly. For larger work it decomposes the range, forks one branch to make it eligible for parallel execution, and computes the other branch locally. It then joins the forked branch and combines both results. Joining before forking cannot make the work parallel, while combining before the join omits a result that may not yet be available.

Building Database Applications with JDBC

1 practice question on this topicWhat this topic covers

Question 14

Added

Multiple Answers

A reporting service uses a JDBC driver supplied by its database vendor and obtains a connection through `DriverManager`. It executes a query whose result can be large, and the service must ensure that database resources are released if iteration or row processing fails. The driver is registered through the standard JDBC provider mechanism, so application code must not instantiate a vendor driver directly. The query is read-only and does not need generated keys. Which two actions best satisfy the resource-management requirement? (Choose two.)

Correct answer: A, E

Try-with-resources closes each declared JDBC resource when control leaves the block, including when iteration or row processing throws; closing the result set, statement, and connection is the appropriate ownership boundary. `DriverManager.getConnection` accepts the JDBC URL and credentials and can use a driver registered through the provider mechanism. Closing only after successful iteration leaks resources on failure. Re-registering the driver for every query is unnecessary under the stated setup. A statement cannot be reused after its connection has been closed.

Localization

1 practice question on this topicWhat this topic covers

Question 15

Added

Single Answer

A desktop application ships English and French message bundles. For a user whose locale is `fr_CA`, it should use a Canadian French bundle if present, otherwise fall back to the general French bundle, and finally to the base bundle. The application must use Java's standard resource-bundle lookup and should not implement its own filename search. Which bundle files provide the intended fallback behavior?

Correct answer: D

For a locale with language `fr` and country `CA`, standard `ResourceBundle` lookup considers the language-and-country bundle, then the language bundle, and then the base bundle (subject to the configured default-locale fallback behavior). These filenames use Java's expected language-country suffix order and provide each requested fallback level. Reversing country and language does not match the standard naming convention. An English bundle is not a general French fallback, and omitting the base bundle removes the final specified fallback.

More Oracle Practice Questions

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

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