Courseiva

1Z0-829 · domain

Java I/O API and Securing Applications

Practise Oracle Certified Professional Java SE 17 Developer 1Z0-829 Java I/O API and Securing Applications practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

80 questions22 easy33 medium25 hard

Focused practice

Practice Java I/O API and Securing Applications questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Java I/O API and Securing Applications

Java I/O API and Securing Applications questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Java I/O API and Securing Applications exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Question index

All Java I/O API and Securing Applications questions (80)

Click any question to see the full explanation, or start a practice session above.

1

A developer needs to write text to a file with UTF-8 encoding. Which class should be used?

Easy
2

Which TWO statements are true regarding reading files with the NIO.2 API?

Medium
3

A financial services company runs a Java 17 application on a server with 8 GB RAM. The application reads daily transaction files in CSV format (each file is about 500 MB). It processes each line, validates it against a SQL database, and writes results to an output file. Recently, after processing about 60% of a file, the application crashes with an OutOfMemoryError: Java heap space. The heap size is set to 2 GB. The code uses Files.readAllLines() to load the entire file into a List<String>, then iterates. The team is evaluating solutions to avoid memory issues. Which approach is the best course of action?

Hard
4

Which THREE statements are true about Java NIO.2 and its interaction with blocking I/O? (Choose three.)

Medium
5

An application must read a configuration file that is updated frequently by another process. The developer wants to avoid stale data and minimize I/O operations. Which approach is best?

Hard
6

Which TWO are true about the try-with-resources statement?

Easy
7

Which TWO practices improve the security of Java serialization?

Medium
8

A Java application running on a server reads configuration from a file 'config.properties' located in the same directory as the JAR. The application uses java.util.Properties.load(InputStream) to read the file. Recently, the file was modified by an unauthorized user, and the application started throwing runtime exceptions due to corrupted property values. The security team requires that the file be protected from unauthorized modifications while still being readable by the application. Which action should be taken to ensure the integrity of the configuration file?

Easy
9

Which THREE statements about the SecurityManager and security policies in Java 17 are true? (Choose three.)

Hard
10

Which is the best practice for securing a Java application that reads sensitive configuration files?

Easy
11

A developer needs to read a very large text file (over 1 GB) efficiently with minimal memory overhead. Which approach is most suitable?

Medium
12

Refer to the exhibit. What is the purpose of this code?

Easy
13

A class that stores sensitive user data implements Serializable. To minimize security exposure from deserialization attacks, which modification is the best practice?

Medium
14

Which class is best suited for reading integer tokens from a string containing space-separated integers?

Easy
15

Refer to the exhibit. A developer runs a keytool command and sees the output above. Which command produced this output?

Medium
16

Refer to the exhibit. What is the most likely cause of this exception?

Hard
17

A web server application writes access logs to a file. To ensure that log entries are written to disk immediately even if the JVM crashes, which approach is most appropriate?

Medium
18

Refer to the exhibit. Which algorithm was used to generate the certificate fingerprint shown?

Easy
19

A Java application writes sensitive user data to a file. To ensure that data is not left in the file system after the application crashes, which practice should be followed?

Easy
20

A web application allows users to specify filenames for uploaded documents. The application saves files to a directory using the provided name. Which secure programming practice should be applied to prevent path traversal attacks?

Easy
21

Which TWO statements about Java serialization are true?

Hard
22

Refer to the exhibit. A Java application is deployed in /opt/app/lib/ and attempts to perform the following operations: 1) Read the file /data/config/settings.xml 2) Write to the file /logs/app.log 3) Read the file /data/config/subdir/extra.conf Which statement is true?

Medium
23

A developer wants to traverse a directory tree to find all files that are symbolic links. Which NIO.2 method should be used to follow symbolic links during traversal?

Medium
24

A class implements Serializable. Which modification ensures that a specific field (password) is not included in the serialized stream?

Medium
25

Which THREE are valid ways to read the contents of a text file into a String in Java?

Hard
26

A serialized object has an explicitly declared serialVersionUID of 123L. After a code change, a new field is added to the class but the serialVersionUID is left unchanged. What happens when deserializing an old stream?

Hard
27

Which resource declaration order in try-with-resources is valid when both a FileInputStream and a BufferedInputStream wrapping it need to be closed automatically?

Easy
28

Which two statements are true about FileInputStream? (Select two.)

Hard
29

A developer is tasked with reading a large binary file (1 GB) from a network share using the least amount of memory possible. Which approach should be used?

Medium
30

A Java application uses FileChannel to copy a file to a remote network drive. The developer wants to ensure atomic file replacement on the destination. Which approach is correct?

Hard
31

Which of the following correctly uses try-with-resources to ensure a FileInputStream is closed after use?

Easy
32

Refer to the exhibit. A security policy file is configured as shown. The application in app.jar tries to read a file named "${user.home}/data/db.properties". What is the result?

Hard
33

A financial application deserializes objects received over the network using ObjectInputStream. To prevent deserialization attacks, which secure coding practice should be implemented?

Medium
34

In a JAAS login module, after the login() method returns true, which method must be called to commit the authentication and add principals to the Subject?

Hard
35

A financial trading application processes real-time stock data from multiple exchanges. The application reads large binary files (each up to 500 MB) containing trade records, processes them, and writes summary reports to a shared network drive. The development team observes that the application occasionally throws a java.io.IOException: 'The process cannot access the file because it is being used by another process' when writing reports. The application is multi-threaded, and each thread writes to a separate file in the same directory. The team also notices that the application slows down significantly when the network drive is under heavy load. The application runs on Windows servers with Java 17. The code uses FileOutputStream for writing and does not explicitly close streams in some paths. Which course of action should the team take to resolve the issues and improve performance?

Hard
36

Which TWO statements about java.io and java.nio.file packages are true?

Medium
37

What is the output?

Hard
38

Which two of the following are valid methods to create a new directory using the NIO.2 Files class? (Select two.)

Easy
39

Which class provides a convenient means to read text from a file line by line?

Easy
40

A large-scale data processing platform uses Java to read and write files across multiple nodes. Recently, operations have slowed down significantly. The system uses FileInputStream and FileOutputStream wrapped in BufferedInputStream and BufferedOutputStream with default buffer sizes (8 KB). The operations team suspects that the default buffer size is causing excessive system calls. The files are typically 100 MB to 1 GB in size. Which change would most improve I/O performance while minimizing memory overhead?

Hard
41

A Java application running in a secure environment needs to read a file located outside the application's directory. Which approach correctly handles security?

Medium
42

A developer needs to create a temporary file that will be automatically deleted when the JVM terminates. Which approach correctly achieves this?

Easy
43

A developer is writing a utility to copy a large binary file (e.g., 500 MB) from one location to another while minimizing memory overhead and ensuring data integrity. Which approach is most appropriate?

Medium
44

Which interface should be implemented to create a custom filter for deserialization in Java?

Easy
45

Which three actions help secure a Java application that uses serialization? (Select three.)

Hard
46

A company uses serialization to transfer objects between microservices. To prevent deserialization attacks, they want to restrict which classes can be deserialized. Which approach should be used in Java 17?

Medium
47

A developer is building a file synchronization tool that runs on multiple threads. Multiple threads may read and write to the same file concurrently. The developer wants to ensure that a thread does not read a file while another thread is writing to it, and that concurrent reads are allowed. Which locking mechanism should be used?

Medium
48

You are developing a Java application that processes sensitive user data. The application runs on a server with strict security policies. You need to read configuration properties from a file located at /etc/app/config.properties. The application uses a SecurityManager. During testing, you get a security exception: java.security.AccessControlException: access denied (java.io.FilePermission /etc/app/config.properties read). You have already added a file permission grant in the policy file for the application codebase. However, the exception persists. What is the most likely cause?

Easy
49

A Java application needs to refer to a file using the path "data/input.txt". To ensure platform independence (correct file separator), which approach is recommended?

Hard
50

A Java application uses SecurityManager with a policy file. Which permission is required to allow the application to read all files in the /var/log directory, including subdirectories?

Medium
51

A web application allows users to upload profile pictures. The application saves the files to a directory using the original filename provided by the user. After a security review, the team discovered a critical path traversal vulnerability. Which remediation is most effective in preventing exploitation while maintaining usability?

Easy
52

Which TWO are secure coding practices for Java I/O that help prevent resource leaks and unauthorized access? (Choose two.)

Hard
53

A Java application reads configuration from a file using FileInputStream. The application must handle the case where the configuration file is missing by logging a warning and using default values. Which design approach best meets this requirement?

Medium
54

A developer is building a batch processing application that reads a large CSV file (approx. 5 GB) from a network file system, transforms each row, and writes the result to a database. The initial implementation uses Files.lines(path) to obtain a Stream<String>, processes each line with forEach, and then does not explicitly close the stream. After running for several minutes, the application slows down, and eventually throws an IOException: 'Too many open files'. The database writes are also failing intermittently. The developer needs to fix the application. The environment is Java 17 on Linux with default settings. Which course of action best resolves the issues?

Hard
55

Which TWO approaches are recommended to secure Java I/O operations? (Choose two.)

Easy
56

A method receives an InputStream and needs to compute its MD5 hash while reading the data. Which approach is most efficient?

Medium
57

An application deserializes objects from a network stream. To protect against deserialization attacks, which approach is most effective in Java 17?

Hard
58

Which THREE are benefits of using the NIO.2 API over the java.io API?

Medium
59

Refer to the exhibit. Assuming the application is running from /home/application/lib/myapp.jar, which of the following actions is allowed by the policy?

Medium
60

Which interface is designed for recursively walking a file tree?

Easy
61

Which TWO secure coding practices should be followed when developing a Java application that handles user input? (Choose two.)

Medium
62

A developer needs to read a large text file (several gigabytes) line by line as efficiently as possible, processing each line without loading the entire file into memory. Which approach should the developer use?

Easy
63

A developer wants to copy all files from one directory to another, preserving file attributes (e.g., last modified time, permissions). Which NIO.2 method is most appropriate?

Medium
64

A logging framework in Java has been writing logs to a file using a FileWriter with default buffer size. The logs are frequently lost when the application crashes because the buffer is not flushed. Which change ensures that log messages are written immediately without significantly impacting performance?

Medium
65

Order the steps to create an immutable class in Java.

Medium
66

Given a requirement to efficiently copy a large file (over 2 GB) from one path to another, which approach is most appropriate for Java NIO.2?

Hard
67

Match each concurrency utility to its purpose.

Medium
68

A company needs to read a large text file (over 2 GB) line by line in a Java application while minimizing memory footprint. Which approach is most efficient?

Medium
69

A class implements Serializable but the developer wants to completely prevent deserialization of its instances. Which approach accomplishes this?

Hard
70

An architect is designing a microservice that reads large CSV files (up to 500 MB) from a shared filesystem and processes each row. The processing is CPU-bound and must not block the main thread. The service is deployed in a container with limited memory (512 MB heap). Which approach is most suitable?

Hard
71

Which statement about java.io and java.nio.file packages is true?

Easy
72

A developer needs to copy a large directory tree from one location to another, preserving file attributes. Which method should be used?

Medium
73

Which THREE are recommended practices to prevent privilege escalation when using doPrivileged in a security-sensitive Java application?

Hard
74

Which TWO statements are true about securing a Java application?

Medium
75

Refer to the exhibit. Which of the following best describes the effective permissions granted to the application?

Medium
76

Refer to the exhibit. What is the most likely cause of this exception?

Hard
77

To generate a cryptographically secure random number for a key generation algorithm, which class should be used?

Medium
78

A developer is designing a service that processes multiple files concurrently. To avoid resource leaks, which practice is essential?

Hard
79

A developer needs to read all lines from a text file named "data.txt" that uses UTF-8 encoding. Which code correctly reads the file using the NIO.2 API?

Easy
80

Which class from the java.nio.file package is most appropriate for efficiently transferring data between two channels on the same machine?

Medium

Frequently asked questions

What does the Java I/O API and Securing Applications domain cover on the 1Z0-829 exam?
Java I/O API and Securing Applications questions test whether you can apply the concept in context, not just recognise a definition.
How many questions are in this domain?
This page lists all 80 Java I/O API and Securing Applications questions in the 1Z0-829 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Java I/O API and Securing Applications questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
Oracle Certified Professional Java SE 17 Developer 1Z0-829 Java I/O API and Securing Applications Practice Questions