ExamDumpster

Free 1Z0-819 sample questions

Real questions from the Java SE 11 Developer (OCP) practice bank, with the correct answer and an explanation for each one. No junk, no filler.

Try them in the simulator Same questions, with study, timed and flashcard modes.

Showing 10 of 20 free sample questions.

Question 1Choose one

A developer is tasked with creating a method that accepts a `java.nio.file.Path` object and returns a `java.io.BufferedReader` for that file. The method must ensure that the file's resources are automatically closed, even if an `IOException` occurs during reading. Which implementation correctly and most concisely achieves this?

Question 2Choose 2

A development team is working on a modularized Java 11 application for a financial institution. The application has the following module structure: - `com.finance.datamodel`: Exports a package `com.finance.datamodel.entities`. - `com.finance.persistence`: Requires `com.finance.datamodel` and handles database operations. - `com.finance.reporting`: Requires `com.finance.datamodel` and generates reports. The team now needs to introduce a new module, `com.finance.core`, which will contain business logic. This new core module needs access to the persistence layer. To achieve loose coupling, they decide to use services. The `com.finance.persistence` module will provide a `PersistenceService` implementation. Which combination of directives must be added to the respective `module-info.java` files to correctly implement this service-based dependency? Select TWO.

Question 3Choose one

You are developing a secure REST API endpoint that accepts a user ID as a path parameter to fetch user details from a database. To prevent unauthorized access, the endpoint must validate that the incoming user ID belongs to the currently authenticated principal. The security framework provides the authenticated principal's user ID via `SecurityContext.getPrincipalId()`. A junior developer has written the initial code. Which code snippet represents the most common security vulnerability in this context?

Question 4Choose one

True or False: In a `try-with-resources` statement that manages multiple resources, the `close()` methods are called in the reverse order of their declaration.

Question 5Choose one

A financial application processes transactions concurrently using a `java.util.concurrent.ExecutorService`. To monitor performance, the team needs to know the total processing time of all completed tasks. Each task is a `Callable ` that returns its execution duration in milliseconds. Which code snippet correctly uses the stream API to invoke all tasks and sum their results?

Question 6Choose one

A developer is writing a utility method to format currency values for different regions. The method should take a `double` and a `java.util.Locale` and return a formatted string. The application will be used in the US, Germany, and Japan. Which is the correct way to instantiate and use a `NumberFormat` object for this purpose?

Question 7Choose one

Given the following code: ```java public class Device { private String type = "electronic"; public String getType() { return type; } } public class Phone extends Device { private String type = "mobile"; @Override public String getType() { return type; } } public class Tester { public static void main(String[] args) { Device device = new Phone(); System.out.println(device.type + ":" + device.getType()); } } ``` What is the result?

Question 8Choose one

A developer needs to process a list of `Order` objects. The goal is to create a `Map` where keys are the `Customer` associated with the order, and values are a `List` of all `Order` objects for that customer. Which stream operation correctly achieves this? graph TD A[List ] --> B{Stream Pipeline} B --> C[Map >]

Question 9Choose 2

A developer has created a custom annotation `@Version` to track the version of a class. The annotation must be available at runtime via reflection and should be included in the generated Javadoc. ```java // line n1 public @interface Version { String value(); } ``` Which meta-annotations should be placed at `line n1` to meet these requirements? (Select TWO)

Question 10Choose one

A developer is implementing a custom collection class that must be usable in a `for-each` loop. Which interface must the custom class implement to support this functionality?

10 more free samples are waiting

Create a free account to unlock the whole 1Z0-819 sample bank, or get full access to all 235 practice questions in the simulator.

Create account