Exam Information
Free practice questions with explanations
Oracle 1Z0-809 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 10
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Advanced Java Class Design
A developer maintains a payment library. The base class PaymentProcessor declares an abstract method authorize(BigDecimal amount) and a concrete method settle() that calls authorize(). A subclass CardProcessor must be prevented from ever overriding settle(), and a constant MAX_RETRIES must never be reassigned after construction. The team also wants a nested type used only inside PaymentProcessor to hold retry state, with no reference to an enclosing instance. Which combination of declarations satisfies all three requirements?
Correct Answer: CExplanationA final instance method cannot be overridden, so settle() must be final. A final instance field can be assigned once per instance, which satisfies the constant requirement as stated, and a static nested class carries no enclosing instance, matching the retry-state need. Making settle() private would hide it from subclasses but would not stop them from declaring a method of the same name, so it does not prevent overriding in the sense required. A non-static inner class would hold an implicit reference to the outer instance, violating the no-reference constraint. Anonymous and local classes cannot be declared as shared nested members of this kind and are not reusable types here.
-
2 Question 2 Single choice Building Database Applications with JDBC
A reporting service on Java SE 8 runs a SELECT against an Oracle database through a PreparedStatement obtained from DriverManager.getConnection(url, user, password). The method returns the ResultSet to its caller, who iterates it after the method has finished. Under heavy load the service begins exhausting database cursors and connections. The team must fix the leak without changing the caller's contract of receiving a ResultSet. Which change is the correct fix?
Correct Answer: AExplanationClosing the ResultSet before returning it would make it unusable, so the connection and statement must remain open until the caller finishes; the caller is then responsible for closing them, which fits the stated contract only if resources are managed deliberately, as in a try-with-resources form the caller can wrap. Returning a ResultSet while closing the Statement or Connection inside the method causes the caller to hit a closed-resource error when iterating. Switching to a DataSource does not change when a connection is released relative to the ResultSet's lifetime. Adjusting fetch size controls row batching, not statement or connection closure, so it does not remove the leak.
-
3 Question 3 Single choice Exceptions and Assertions
A file-ingestion service reads records from a file and writes them to a database through a custom resource class IngestSession that implements AutoCloseable. Its close() method may throw an IOException that is independent of any exception thrown by the body. A developer writes a try-with-resources block whose body throws a ParseException. Operations must log the parse failure while still surfacing a close failure if one occurs, and no suppressed information may be lost. Which implementation meets these requirements?
Correct Answer: BExplanationIn try-with-resources, the close() exception is added as suppressed to the primary ParseException when both occur, and a catch clause attached to the statement receives the primary exception with suppressed ones attached. A multi-catch after the block can handle both the primary and any close failure that propagates, and logging each preserves visibility. An explicit finally close would duplicate the resource handling and risk masking the original ParseException by throwing from finally. Calling close manually in the catch block would close the resource twice when the implicit close also runs. Checking getSuppressed only when close is known to fail is not a valid pattern, since the suppression is automatic and the caller cannot know in advance.
-
4 Question 4 Single choice Generics and Collections
A scheduling module must keep pending jobs ordered by priority, where priority is an int and ties are broken by the job name alphabetically. Jobs are stored in a TreeSet, and the team wants a clean, reusable ordering rather than duplicate logic in each caller. The class Job has a name field and an int priority field. Two jobs with the same name must be treated as duplicates by the set. Which change correctly implements the required ordering?
Correct Answer: BExplanationA TreeSet decides membership and ordering through its comparator or the natural ordering from Comparable, not through hashCode or equals. Comparing priority then name in compareTo gives the required ordering, and because compareTo returns zero only when both fields match, the set treats such jobs as duplicates. A comparator that ignores name would collapse distinct jobs with equal priority into one entry, losing jobs. Relying on hashCode is meaningless for a TreeSet. A HashSet does not maintain order, so sorting copies on each read is an unnecessary approach that conflicts with the goal of a clean ordered structure.
-
5 Question 5 Multiple choice Java Concurrency
A batch service spawns tasks through an ExecutorService that share a counter and a status list. Intermittent wrong totals and occasional ConcurrentModificationException errors appear under load. The team must eliminate the races without serializing all work. Which TWO changes correctly address these problems? (Choose two.)
Correct Answer: C, DExplanationAtomicInteger.incrementAndGet performs an atomic read-modify-write, removing the lost-update race on the counter without blocking all tasks. CopyOnWriteArrayList iterates over a snapshot of its array, so iteration during concurrent modification does not throw ConcurrentModificationException. Synchronizing run() serializes every task, which contradicts the requirement to avoid serializing the work. Marking the counter volatile guarantees visibility but not atomicity of increment. A CyclicBarrier with one party does not guard the list update and adds waiting without protection.
-
6 Question 6 Order list Java File I/O (NIO.2)
A deployment script must safely replace a configuration file config/app.properties with a new version staged in a temporary directory, then remove the staging copy. Drag the steps into the correct order.
Drag the steps into the correct order, or use the arrows.
- Delete the staged file staging/app.properties.
- Copy staging/app.properties over config/app.properties using Files.copy with REPLACE_EXISTING.
- Create the config directory if it is missing using Files.createDirectories.
- Check that staging/app.properties exists using Files.exists.
Correct Answer:- Create the config directory if it is missing using Files.createDirectories.
- Check that staging/app.properties exists using Files.exists.
- Copy staging/app.properties over config/app.properties using Files.copy with REPLACE_EXISTING.
- Delete the staged file staging/app.properties.
ExplanationThe source must be verified before anything is done with it, but the destination directory must exist before the copy can succeed, so creating it is needed before copying. Checking the staged file with Files.exists comes before the copy, and the copy with REPLACE_EXISTING overwrites the old config file. Deleting the staging copy only after a successful copy ensures no data is lost. Copying before creating the directory would throw NoSuchFileException. Checking existence after the copy would not guard the copy itself, and deleting the staged file before copying would remove the source.
-
7 Question 7 Single choice Java Stream API
A product catalogue is held in a List, where each Product has a category (String), a price (double), and an inStock flag (boolean). Match each reporting requirement to the Stream API construct that satisfies it.
1. Report whether every product in a category is out of stock
2. Group the products by category into a Map
3. Split the products into those priced above 100 and those not, with a Map
4. Produce the first in-stock product found, wrapped to avoid null
Which mapping is correct?Correct Answer: AExplanationnoneMatch returns true only when no element satisfies the predicate, which matches checking that a category is entirely out of stock when the predicate is inStock. groupingBy produces a map keyed by category, while partitioningBy is the right choice for a two-part Boolean split. findFirst returns an Optional for the first element of an ordered stream and is the stated requirement, whereas findAny carries no ordering guarantee. Mixing up groupingBy and partitioningBy or using anyMatch for the all-out-of-stock check would break the stated semantics.
-
8 Question 8 Dropdown Lambda Built-in Functional Interfaces
A pricing engine applies a discount to a double amount and needs a function that takes a double and returns a double without boxing. The developer writes: DoubleUnaryOperator discount = x -> x * 0.9; Which pair of types completes the declarations correctly? Choose the correct value for each blank.
Choose the correct value for each blank.
A second component needs a predicate over int values and a supplier of Strings. The developer declares for the int predicate and for the String supplier to avoid boxing where the primitive form exists.Correct Answer:A second component needs a predicate over int values and a supplier of Strings. The developer declares IntPredicate for the int predicate and Supplier for the String supplier to avoid boxing where the primitive form exists.
ExplanationIntPredicate is the primitive form that takes an int and returns boolean, avoiding the boxing that Predicate would introduce. Supplier is the correct functional interface for producing a String, and no primitive variant exists for reference types. Predicate boxes each int value, which the requirement forbids. Function is not a supplier and cannot be invoked without an argument, and UnaryOperator returns an Integer rather than a boolean predicate result.
-
9 Question 9 Single choice Localization
A retail application ships messages in English and German. Resource bundles are named Messages.properties, Messages_de.properties, and Messages_de_AT.properties. A user requests the locale de_CH, for which no bundle exists. The code calls ResourceBundle.getBundle("Messages", locale). The team wants German-speaking users in Switzerland to see the German bundle rather than the base English bundle. What must they do?
Correct Answer: AExplanationResourceBundle candidate lookup drops the variant and then the country, so de_CH falls back to the de bundle, and the existing Messages_de.properties already supplies German text. Adding a country-specific bundle is unnecessary for this goal. The default locale is consulted only after the requested locale's candidate list is exhausted, so setting it to de_AT would not change the result for de_CH. Renaming the Austrian bundle would remove German text for Austria and does not match the fallback behaviour the team needs.
-
10 Question 10 Single choice Use Java SE 8 Date/Time API
A scheduling service stores a meeting as a ZonedDateTime for 01:30 on 2024-03-10 in America/New_York, which is the day clocks move forward at 02:00 to 03:00. A developer wants to add exactly 1 hour of elapsed time to the meeting and also to add 1 day of calendar time to a second meeting stored as LocalDateTime. The team must keep the results correct across the DST gap. Which pair of operations gives the correct results?
Correct Answer: BExplanationDuration measures elapsed time, so adding Duration.ofHours(1) to a ZonedDateTime moves the instant forward by one real hour, handling the DST jump correctly. Period represents calendar-based amounts such as days, so adding Period.ofDays(1) to a LocalDateTime advances the date by one day as intended. Period.ofHours does not exist and would fail to compile. Duration.ofDays(1) adds 24 hours of elapsed time, which is not the same as a calendar day across a DST change. Adding Period.ofDays to a ZonedDateTime is valid but the stem asks for elapsed hours there, so pairing it with a Duration on the LocalDateTime misapplies the types.
These are 10 of the 208 questions in the full 1Z0-809 pack.
Get All 208 QuestionsGet all 208 questions & answers
Full access options for Oracle 1Z0-809
Self-study
PDF Version
- 208 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 208 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 208 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the 1Z0-809 Exam (Java SE 8 Programmer II) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.