Free 1Z0-829 sample questions
Here are free 1Z0-829 sample questions on Java SE 17, each with the answer and an explanation. They test records, streams, concurrency and the module system. Run any code you are unsure about in your own editor to confirm the result.
Try them in the simulator Same questions, with study, timed and flashcard modes.
Showing 10 of 20 free sample questions.
A developer is implementing a thread-safe counter. To avoid the overhead of explicit locking, they decide to use `java.util.concurrent.atomic.AtomicInteger`. Which statement accurately describes the primary mechanism that makes `AtomicInteger` thread-safe without traditional locks?
A developer needs to format monetary values for an e-commerce application that serves customers in Germany and the United States. Given the following code, what is the expected output?
A developer has a `List >` and wants to get a `List ` containing all non-empty string values. Which of the following stream pipelines correctly and most efficiently accomplishes this?
**Case Study:** A logistics company is modernizing its package tracking system. The system needs to represent different types of packages, each with specific attributes. The requirements are as follows: 1. There are three and only three types of packages: `Standard`, `Express`, and `Fragile`. 2. No other package types should be permissible in the system to ensure strict domain modeling. 3. A `Standard` package has a weight. 4. An `Express` package has a weight and a priority level (an integer). 5. A `Fragile` package has a weight and special handling instructions (a String). 6. All package types should be immutable data carriers. A senior developer proposes using a combination of sealed interfaces and records to model this domain. The goal is to create a type-safe hierarchy that can be effectively processed, for example, in a `switch` expression for calculating shipping costs. Which code implementation best satisfies all the given requirements?
A developer is writing a JDBC utility to fetch user data. They need to ensure that the `Connection` and `PreparedStatement` are always closed, even if an exception occurs during result set processing. Which code structure provides the most robust and modern approach to achieve this?
True or False: In the Java Platform Module System (JPMS), if module `A` requires module `B` (`requires B;`), and module `B` exports package `p1` (`exports p1;`), then module `A` can access public types in package `p1` by default.
A developer is working with a `java.util.concurrent.ExecutorService` to run asynchronous tasks. After submitting all tasks, the developer wants to shut down the service gracefully, allowing currently executing tasks to finish but rejecting any new tasks. Which method should be called on the `ExecutorService` instance?
Consider the following record definition and its usage. What will be the output of this program?
A developer is serializing an object of class `Employee`. The `Employee` class contains a field for a password, which should not be saved to disk for security reasons. The class also needs to maintain a version UID for compatibility. Which two modifications are necessary to achieve this? (Select TWO)
10 more free samples are waiting
Create a free account to unlock the whole 1Z0-829 sample bank, or get full access to all 906 practice questions in the simulator.