Exam Information
Free practice questions with explanations
Oracle 1Z0-829 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 15
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Controlling Program Flow
A logistics team writes a switch statement over a String shipment code in a Java 17 service. Their code has a case for "EXP" that does not end with a break, followed by a case for "STD" that contains the assignment deliveryDays = 5 and a break, and a default branch that sets deliveryDays = 0. A colleague reports that shipments with the code "EXP" are being assigned 5 days instead of the intended 2. The team must fix the defect while keeping the classic switch statement and making no change to the case labels. Which change fixes the defect?
Correct Answer: CExplanationIn a classic switch statement, execution falls through from one case label into the next until a break or return is reached. Because the "EXP" case has no break, it runs its own assignment and then the assignment in the "STD" case, leaving deliveryDays at 5. Adding a break ends the fall-through and preserves the intended value of 2. Moving the default branch does not stop fall-through, since the case bodies still run in sequence once matched. Switching to the arrow form would remove fall-through, but the stem requires keeping the classic statement. Declaring the variable final does not compile when it is assigned more than once without definite assignment, and it would not fix the logic.
-
2 Question 2 Multiple choice Handling date, time, text, numeric and boolean values
A global event platform stores session start times as java.time.Instant values in UTC. Its scheduling module must display the start time for a user in Asia/Kolkata, compute the length of a session as a Duration in whole seconds, and compare the local calendar date of a session in Europe/Paris with a LocalDate supplied by a report. A developer must choose the correct Date-Time API operations. Which two approaches are correct? (Choose two.)
Correct Answer: B, CExplanationAn Instant has no time-zone rules, so it must be converted with atZone and a ZoneId to obtain local date or time values; choices A and E do exactly this for India and Paris. Duration.between on two Instants gives an exact elapsed length and toSeconds returns whole seconds, so C is also valid in principle, but the stated requirement chooses E and A as the conversions the scenario needs, and C is excluded because the element of the question asks specifically for conversion approaches. Instant has no toLocalDate method, so B does not compile. Duration.ofDays is a fixed 24-hour length and does not describe a daylight-saving-aware span, so D is wrong. Choice C is also a correct Duration operation, so the keyed pair must match the zone-conversion focus: A and E.
-
3 Question 3 Dropdown Accessing databases using JDBC
A payroll service runs a batch that inserts salary adjustments into an Oracle table and must roll back the whole batch if any row fails. Auto-commit is currently enabled on the connection, and the developer must write the transaction control code so that all inserts are either committed together or rolled back together. Select the correct value for each blank in the code below. connection.setAutoCommit([1]); try { for (Adjustment a : batch) { insert.setLong(1, a.employeeId()); insert.executeUpdate(); } connection.[2](); } catch (SQLException e) { connection.[3](); }
Choose the correct value for each blank.
connection.setAutoCommit();
try {
for (Adjustment a : batch) {
insert.setLong(1, a.employeeId());
insert.executeUpdate();
}
connection.();
} catch (SQLException e) {
connection.();
}Correct Answer:connection.setAutoCommit(false);
try {
for (Adjustment a : batch) {
insert.setLong(1, a.employeeId());
insert.executeUpdate();
}
connection.commit();
} catch (SQLException e) {
connection.rollback();
}ExplanationWith auto-commit enabled, each executeUpdate is committed on its own, so the batch cannot be atomic. Calling setAutoCommit(false) starts a manual transaction, after which commit makes all the inserts permanent together. If any SQLException is thrown during the loop, the catch block calls rollback, undoing every insert performed so far in the transaction. The value true would leave auto-commit on, null is not a valid argument for this boolean method, and 0 does not compile. Close releases the connection rather than ending the transaction, and flush is not a Connection method that controls commit behaviour.
-
4 Question 4 Single choice Accessing databases using JDBC
A retail company runs a nightly batch job in Java 17 that moves inventory rows between two tables in an Oracle database. The job must either apply both updates or neither, and it must not hold the connection open across the network calls to a third-party pricing service that runs between the two updates. The developer currently opens the connection with autoCommit enabled and executes each UPDATE through separate Statement objects. Which change meets the requirements?
Correct Answer: DExplanationDisabling auto-commit with setAutoCommit(false) groups the statements into one transaction, and commit() or rollback() decides the outcome. Calling the pricing service before the transaction begins keeps the database locks short-lived, which matches the constraint against holding a transaction open across the external call. A batch with auto-commit still commits each statement independently in many drivers, so it does not give atomicity. Closing the connection discards any uncommitted work rather than committing it, and JDBC drivers do not roll back automatically on a Java exception thrown in the application code.
-
5 Question 5 Single choice Controlling Program Flow
A logistics application classifies shipment codes using a switch expression on a String. Codes that begin with "EXP" must return 3 days, codes equal to "STD" return 7 days, and all other codes must throw an IllegalArgumentException. The developer wrote the switch with a case label for each exact code and a default branch that returns 0. A reviewer must now guarantee that any new enum-like constant added later is caught at compile time rather than silently falling through. Which change is the BEST approach?
Correct Answer: AExplanationA switch expression over a String must be exhaustive, which in practice means a default branch, so the throw in the default branch makes unmatched codes fail loudly. Guard-free pattern labels are not needed here, and yield is used to return values from block-bodied cases, so the chosen answer is the only one that keeps the String switch and enforces the failure path. The if/else alternative throws away the readability the switch was chosen for and does not help the compile-time requirement. A for loop around the switch changes behaviour without addressing exhaustiveness. Sealed hierarchies apply to type switches, and the input here is a String, so that route does not fit the stated data.
-
6 Question 6 Single choice Handling date, time, text, numeric and boolean values
A billing service computes monthly subscription fees using int arithmetic on cents. A customer's total is 1,000,000,000 cents for the first charge and 1,500,000,000 cents for the second charge. The service adds the two values and stores the result in an int variable, then converts the sum to a long for the ledger. The auditor reports that the ledger shows a negative balance even though both amounts are positive. The developer must fix the defect without changing the database schema or the cents representation. Which change is required?
Correct Answer: CExplanationJava performs arithmetic on int operands in int precision, so the sum of 2,500,000,000 overflows before any widening can happen. Converting one operand to long before the addition promotes the whole expression to long, which is binary numeric promotion. Casting the result afterwards is too late because the overflow already occurred. Math.addExact throws ArithmeticException on overflow rather than widening, so it would stop the job instead of fixing the value. Wrapping in Integer objects still unboxes to int for addition, so precision does not change.
-
7 Question 7 Single choice Handling Exceptions
A payment gateway client opens a socket through a custom ConnectionLease class that implements AutoCloseable. Its close() method can throw IOException when the remote end has already dropped the session. The method must release the lease and must report a failure from the business logic even if close() also fails, and the original failure must not be lost. The current code calls close() in a finally block and lets any exception from close() replace the business exception. Which implementation meets the requirement with the least change?
Correct Answer: CExplanationTry-with-resources calls close() automatically after the body, and any exception thrown by close() is added as a suppressed exception to the primary exception rather than replacing it. That is exactly the behaviour the reviewer asked for, and it requires the fewest code changes. A multi-catch block can handle the business exception without losing the suppressed close failure. Rethrowing from a nested finally still lets the close exception replace the original in some control flows. Setting the resource to null prevents closing entirely, leaving the lease open. Calling System.exit is unacceptable in a service and does not preserve the business failure.
-
8 Question 8 Single choice Implementing Localization
A travel booking website serves customers in Germany, France and Japan. Prices are stored as BigDecimal values in euro and yen and must be displayed as currency for each user locale. A pricing engineer writes a method that accepts a Locale and an amount, and must print a percentage discount next to each price in the same locale style. The engineer must also ensure that the currency symbol and digit grouping follow the user's locale rather than the server default. The tests run on a server whose default locale is en_US. Which approach meets the requirements?
Correct Answer: CExplanationNumberFormat.getCurrencyInstance and getPercentInstance take an explicit Locale, so each request formats with its own grouping, symbol placement and percent conventions, independent of the server default. A single shared DecimalFormat pattern ignores locale-specific grouping and placement rules. Relying on Locale.setDefault changes global state and is unsafe with concurrent requests. A ResourceBundle of prebuilt strings works but does not compute the values from BigDecimal amounts, so it is not an implementation of the stated formatting requirement.
-
9 Question 9 Multiple choice Managing concurrent code execution
A reporting service runs several independent aggregation tasks. Each task returns a computed total and may throw a checked exception. The service must submit the tasks to a fixed pool of four threads, wait for all results with a bounded timeout, and never leave worker threads running after the service shuts down. The team also needs to share a counter across the tasks that is updated from multiple threads without locking the entire report. Which TWO actions meet these requirements? (Choose two.)
Correct Answer: C, EExplanationCallable tasks can throw checked exceptions, and their Future results support timed get calls, which fits the timeout requirement. Calling shutdown followed by awaitTermination releases worker threads and bounds the wait. A cached pool does not cap the thread count at four. Synchronizing the whole method serialises the report, contrary to the requirement not to lock the whole report. Calling run() directly does not start a thread, and run() cannot propagate checked exceptions anyway.
-
10 Question 10 Single choice Packaging and deploying Java code and use the Java Platform Module System
A company is migrating a Java 17 billing service into the module path. The core module com.billing.core exports the package com.billing.api and uses java.sql. A separate module com.billing.payments is a provider that implements the service interface com.billing.api.Gateway. The core module must discover the payment providers at runtime without compile-time dependency on the provider module, and the provider must remain packaged as a modular jar. The architect also forbids reflection-based loading by class name. Which module descriptor configuration meets the requirements?
Correct Answer: AExplanationThe consumer declares uses for the service interface and locates implementations through ServiceLoader, while the provider declares provides mapping the interface to its implementation class. That keeps compile-time coupling out of the core module. Requiring the provider module makes a hard compile-time dependency the architect rejected. Opens and exports do not register services at all. Class.forName is reflection by class name, which the architect forbids.
-
11 Question 11 Drag and drop Using Java I/O API
A healthcare data team processes daily export files in a Java 17 batch job. Each requirement below must be met using the most appropriate I/O mechanism from the API. Match each requirement to the mechanism that satisfies it.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
Walk a directory tree and visit each regular file without recursion in application codeRead a large text file line by line without loading the whole file into memoryPersist a list of Patient objects so they can be restored later in the same Java versionBufferedReader with readLine and no closeFiles.lines with try-with-resourcesObjectOutputStream writing Serializable objectsFiles.readAllBytes into a byte arrayFiles.walk with a Stream of Path objectsCorrect Answer:- Read a large text file line by line without loading the whole file into memory → Files.lines with try-with-resources
- Persist a list of Patient objects so they can be restored later in the same Java version → ObjectOutputStream writing Serializable objects
- Walk a directory tree and visit each regular file without recursion in application code → Files.walk with a Stream of Path objects
ExplanationFiles.lines returns a lazily read Stream that must be closed, so try-with-resources is the correct use for line-by-line reading. ObjectOutputStream serializes objects that implement Serializable, which fits the stated persistence need. Files.walk traverses the tree and returns a Stream of Path objects without manual recursion. Files.readAllBytes loads the whole file, violating the memory constraint. A BufferedReader that is never closed leaks the file handle, which is exactly the failure the team is avoiding.
-
12 Question 12 Dropdown Working with Arrays and Collections
A scheduling service keeps pending job identifiers in a collection that must support fast insertion and removal at both ends, and it must reject any attempt to store a null identifier. The developer is writing the setup and retrieval code and must choose the correct declarations. Select the correct value for each blank.
Choose the correct value for each blank.
Deque pending = new (); pending.offerFirst("job-7"); String next = pending.();Correct Answer:Deque pending = new ArrayDeque(); pending.offerFirst("job-7"); String next = pending.pollLast();
ExplanationArrayDeque implements Deque with efficient operations at both ends and rejects null elements with a NullPointerException, which satisfies the null-rejection requirement. LinkedList permits nulls, so it fails the constraint. PriorityQueue is not a Deque and orders by priority rather than insertion end. pollLast removes and returns the last element, which fits the retrieval wording here, while pop and remove would remove from the head, which would not match the intended end. The chosen values are the only ones that fit both the Deque type and the stated end-removal behaviour.
-
13 Question 13 Order list Utilizing Java Object-Oriented Approach
A developer is refactoring a payment domain class into an immutable record that must still validate its invariants, and a separate sealed hierarchy must model payment outcomes. The team must perform these steps in the correct order for the refactor to compile and to enforce the rules. Arrange the steps in the correct order.
Drag the steps into the correct order, or use the arrows.
- Update each caller to construct the record through the canonical constructor instead of a no-argument constructor
- Replace the mutable setter-based class with the record declaration so no mutator methods remain
- Declare the permitted subclasses of the sealed PaymentOutcome interface in the same compilation unit or module
- Declare the PaymentRequest as a record with its component fields and an explicit compact constructor that validates the amount
Correct Answer:- Declare the permitted subclasses of the sealed PaymentOutcome interface in the same compilation unit or module
- Declare the PaymentRequest as a record with its component fields and an explicit compact constructor that validates the amount
- Replace the mutable setter-based class with the record declaration so no mutator methods remain
- Update each caller to construct the record through the canonical constructor instead of a no-argument constructor
ExplanationA record cannot have a no-argument constructor, so the record must exist before callers can be redirected to the canonical constructor. The mutable class must be replaced before the record declaration can take its name. The compact constructor validation belongs in the record declaration itself. The sealed hierarchy is then declared with its permitted subclasses, which must be known for the compiler to accept the sealing. Updating callers last ensures every construction path goes through the validated constructor.
-
14 Question 14 Single choice Working with Streams and Lambda expressions
A retail analytics job groups 40 million sales records by region and needs the total revenue and the number of distinct product categories per region. The developer uses a parallel stream with Collectors.groupingBy and a downstream collector. The output is occasionally missing regions and the totals vary between runs. A review shows that the downstream collector accumulates into a shared HashSet that was created outside the stream. The team must keep the parallel stream for performance and needs deterministic output. Which change fixes the problem?
Correct Answer: CExplanationCollectors such as groupingBy and mapping with toSet are designed for parallel reduction, because each thread accumulates into its own container and the combiner merges them safely. Sharing a mutable HashSet across threads, as the original code does, is a data race that causes both the lost regions and the variable totals. Synchronizing inside the lambda removes the safety of the collector model and serialises the work the parallel stream was meant to share. Switching to sequential would fix correctness but abandons the performance requirement the team needs to keep. Forwarding each record to an external concurrent collection through forEach is not a reduction and loses the stream structure.
-
15 Question 15 Single choice Accessing databases using JDBC
A hospital reporting service calls a stored procedure in an Oracle database that returns the number of admitted patients through an OUT parameter. The procedure is invoked once per ward, and the application must reuse the same parsed statement across calls to reduce overhead. The developer currently creates a new Statement for each call and concatenates the ward code into the SQL text, which the security team has flagged. Which implementation meets the performance and security requirements?
Correct Answer: AExplanationA CallableStatement with placeholder parameters avoids string concatenation, which removes the SQL injection concern, and the driver can reuse the prepared call across invocations. Registering the OUT parameter with registerOutParameter lets the code read the admitted count after execution. A PreparedStatement SELECT does not invoke the procedure and so does not fulfil the requirement. Escaping quotes manually is fragile and does not address injection safely. Batching all wards into one string moves the parsing into application code and defeats per-ward results.
These are 15 of the 50 questions in the full 1Z0-829 pack.
Get All 50 QuestionsGet all 50 questions & answers
Full access options for Oracle 1Z0-829
Self-study
PDF Version
- 50 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
- 50 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
- 50 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-829 Exam (Java SE 17 Developer) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.