Java Files Advanced: Attributes, walk, find, lines and mark/reset (OCP 21)
Advanced I/O for the OCP 21 exam: mark, reset and skip on input streams, isHidden, isReadable and isExecutable, BasicFileAttributes and views, setTimes, Files.walk with depth limits and FOLLOW_LINKS cycles, Files.find with a BiPredicate, and DirectoryStream.
kvi5hnuCode Sprout team member10 min readOn this page
This last I/O article covers features that come up less often, but they're exactly what tricky exam questions test. First, moving around inside an input stream with mark(), reset() and skip(). Then reading file attributes, singly or all at once. Finally, visiting a whole directory tree with Files.walk() and Files.find(). Files.list() (article 84) and Files.lines() (article 88) complete the set of stream-returning Files methods.
mark(), reset() and skip()
InputStream and Reader both have four methods for moving within the data:
| Method | What it does |
|---|---|
boolean markSupported() | true if this stream really supports mark/reset |
void mark(int readLimit) | Remembers the current position. You promise to call reset() within readLimit more bytes or chars. |
void reset() throws IOException | Goes back to the marked position |
long skip(long n) throws IOException | Reads and discards up to n values, and returns how many were actually skipped |
mark/reset doesn't push data back into the source. The stream keeps the bytes read since the mark in a memory buffer, which is why a huge readLimit costs memory. Support varies by class:
- Supported:
BufferedInputStream,BufferedReader,ByteArrayInputStream,CharArrayReader,StringReader. - Not supported:
FileInputStream,FileReader,InputStreamReader, and most low-level streams. On these,reset()throwsIOException("mark/reset not supported").Reader.mark()itself throws too, whileInputStream.mark()silently does nothing. Wrapping such a stream in a buffered stream adds support.
So always check markSupported() first, and arrange your reads so the stream ends up in the right place either way:
static String readWithMark(InputStream in) throws IOException {
var sb = new StringBuilder().append((char) in.read()); // C
if (in.markSupported()) {
in.mark(10);
sb.append((char) in.read()).append((char) in.read()); // E D
in.reset(); // back to before E
}
for (int b; (b = in.read()) != -1; ) sb.append((char) b);
return sb.toString();
}
// "CEDAR" in a ByteArrayInputStream → CEDEDAR; in a FileInputStream → CEDAR
A few edge cases to know:
- Reading past the
readLimitmay make the mark invalid.BufferedReaderthen throwsIOException: Mark invalidonreset(). Some classes are more lenient (ByteArrayInputStreamignores the limit), but don't rely on it. - Calling
reset()withoutmark()behaves differently by class.BufferedReaderthrowsIOException: Stream not marked.ByteArrayInputStreamjumps back to the start, because its mark starts at position 0. skip(n)near the end returns a smaller number. For example,skip(1000)with 3 bytes left returns3. A plainread()whose result you ignore works likeskip(1).InputStream.skipwith a negative value returns0, while mostReaders throwIllegalArgumentException.
Checking file properties
Files has a simple boolean method for each common property. Article 85 covered exists, isDirectory, isRegularFile and isSymbolicLink. These four check access:
| Method | true when | Checked exception? |
|---|---|---|
Files.isHidden(path) | The file is hidden: on Unix-like systems the name starts with .; on Windows the DOS hidden attribute is set | Yes, IOException |
Files.isReadable(path) | It exists and this process may read it | No, returns false if missing |
Files.isWritable(path) | It exists and may be modified | No, returns false if missing |
Files.isExecutable(path) | It exists and may be run (directories: entered) | No, returns false if missing |
The file extension decides nothing: a .png can be executable and a .sh can be not executable. Remember too that isDirectory and isRegularFile follow symbolic links (a link to a directory gives isDirectory() == true), unless you pass LinkOption.NOFOLLOW_LINKS. isSymbolicLink checks the link itself.
Reading attributes in bulk
Each Files.isXxx() or Files.size() call can mean a separate round trip to the file system. If you need several attributes, read them all in one call into an attributes object:
BasicFileAttributes a = Files.readAttributes(path, BasicFileAttributes.class);
a.isRegularFile(); a.isDirectory(); a.isSymbolicLink(); a.isOther();
a.size(); a.lastModifiedTime(); a.lastAccessTime(); a.creationTime();
a.fileKey(); // a unique id where the file system has one, else null
The method's signature is <A extends BasicFileAttributes> A readAttributes(Path, Class<A>, LinkOption...), and it throws IOException. The returned object is a read-only snapshot.
To change attributes, ask for an updatable view instead:
BasicFileAttributeView view =
Files.getFileAttributeView(path, BasicFileAttributeView.class);
BasicFileAttributes now = view.readAttributes(); // views can read too
view.setTimes(FileTime.from(Instant.parse("2030-04-01T09:30:00Z")), null, null);
// lastModified lastAccess creation: null = unchanged
getFileAttributeView doesn't throw a checked exception, and it returns null if this file system doesn't support the view. Views can only change metadata. No view can turn a file into a directory, and the size changes only when the content does.
| Attributes (read-only) | View (updatable) | Available on |
|---|---|---|
BasicFileAttributes | BasicFileAttributeView | every file system, which is what the exam needs |
DosFileAttributes | DosFileAttributeView | Windows-style: adds hidden, readOnly, archive, system |
PosixFileAttributes | PosixFileAttributeView | Unix, Linux, macOS: adds owner, group, permissions |
Asking readAttributes for an unsupported type throws UnsupportedOperationException. Attributes can also be read by name: Files.getAttribute(path, "basic:size"), Files.readAttributes(path, "size,lastModifiedTime") (returns a Map<String,Object>), and Files.setAttribute(path, "dos:hidden", true). Without a prefix, basic: is assumed.

Walking a directory tree: Files.walk
Files.list(dir) shows one level. Files.walk visits every descendant:
public static Stream<Path> walk(Path start, FileVisitOption... options) throws IOException
public static Stream<Path> walk(Path start, int maxDepth, FileVisitOption... options) throws IOException
- Depth-first: the walk goes all the way down one branch before moving to the next. Each directory comes before its contents, and the start path is the first element. The order of siblings depends on the file system, so sort the results if you need a fixed order.
- Lazy: entries are read as the stream asks for them, so even huge trees use little memory. The stream holds open directory handles, so always use try-with-resources.
- Depth: the start path itself is depth 0. Without a limit the maximum is
Integer.MAX_VALUE.walk(start, 1)gives the start plus its direct children,walk(start, 0)gives only the start, and a negative depth throwsIllegalArgumentException. - Walking a regular file returns a stream with just that file. A missing start path throws
NoSuchFileExceptionright away. Problems during the walk show up asUncheckedIOException, because a stream can't throw checked exceptions.
Totalling sizes is a classic example. Files.size throws IOException, so it's wrapped in a helper that converts it to UncheckedIOException:
static long size(Path p) {
try { return Files.size(p); }
catch (IOException e) { throw new UncheckedIOException(e); }
}
try (Stream<Path> s = Files.walk(root)) {
long total = s.filter(Files::isRegularFile).mapToLong(Solution::size).sum();
}
Symbolic links and cycles
Most NIO.2 methods follow symbolic links unless you pass NOFOLLOW_LINKS. walk is the opposite: by default it doesn't follow links. A link appears in the stream as an entry, but the walk doesn't go into it. Pass FileVisitOption.FOLLOW_LINKS to follow links. Then a link pointing back up to an ancestor directory would cause an endless loop, so walk keeps track of the directories it has visited. When it finds a cycle it throws FileSystemLoopException (an IOException), wrapped in UncheckedIOException because it happens while the stream is being consumed.
Searching: Files.find
find is walk with a built-in filter that gets the file's attributes for free:
public static Stream<Path> find(Path start, int maxDepth,
BiPredicate<Path, BasicFileAttributes> matcher,
FileVisitOption... options) throws IOException
try (Stream<Path> s = Files.find(root, 10,
(p, a) -> a.isRegularFile() && p.toString().endsWith(".txt") && a.size() > 5)) {
s.forEach(System.out::println);
}
Differences from walk to remember:
maxDepthis required. There's no overload without it.- The matcher is a
BiPredicate<Path, BasicFileAttributes>, not aPredicate<Path>. The attributes are already loaded, so the lambda doesn't need to call methods likeFiles.sizethat throw checked exceptions. - It supports
FOLLOW_LINKSin the same way aswalk.
DirectoryStream: the older way
Before streams, a directory was listed with DirectoryStream, and you'll still see it on the exam and in older code:
try (DirectoryStream<Path> dir = Files.newDirectoryStream(path, "*.{txt,java}")) {
for (Path entry : dir) System.out.println(entry.getFileName());
}
It's an Iterable<Path>, not a Stream, and it covers one level only. It can take a glob filter (*, ?, {a,b}, [abc]). You can iterate it only once: a second iterator() call throws IllegalStateException. For new code, Files.list, walk or find usually reads better.
What's current
- Every API in this article is unchanged from Java 21 to 25, and none is deprecated.
Files.walkFileTree(start, FileVisitor)(Java 7) is the callback-based alternative behindwalk. ImplementSimpleFileVisitorand returnCONTINUE,SKIP_SUBTREEand so on. It gives finer control, such as pruning a subtree, but it isn't on the OCP 21 objectives.InputStream.skipNBytes(n)(Java 12) skips exactlynbytes or throwsEOFException, avoiding the "check the return value" trap ofskip.InputStream.transferTo(Java 9) andReader.transferTo(Java 10) copy a whole stream.- On Windows, creating symbolic links needs Developer Mode or administrator rights.
Files.createSymbolicLinkotherwise fails with aFileSystemException.
Exam traps from this article
A complete example
The program below builds a small garden-themed tree in a temporary directory and shows each feature in turn:
- mark/reset with and without support,
skip's return value and the invalid-reset cases - the access checks, including a hidden file (set through the DOS view on Windows) and an executable script (set through the POSIX view on Unix)
- bulk attributes and
setTimes walkat several depths with a size total- a symbolic-link cycle
findand a globbedDirectoryStream
All paths are printed relative to the temp directory and sorted, so the output is the same on every run.
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.time.Instant;
import java.util.*;
import java.util.stream.*;
public class Solution {
/** Prints the same letters' positions whether or not mark() is supported. */
static String readWithMark(InputStream in) throws IOException {
var sb = new StringBuilder();
sb.append((char) in.read()); // C
if (in.markSupported()) {
in.mark(10); // remember this spot (up to 10 bytes ahead)
sb.append((char) in.read()); // E
sb.append((char) in.read()); // D
in.reset(); // back to just before E
}
for (int b; (b = in.read()) != -1; ) sb.append((char) b);
return sb.toString();
}
static String attempt(Callable action) {
try {
return String.valueOf(action.call());
} catch (Exception e) {
return e.getClass().getSimpleName() + " (" + e.getMessage() + ")";
}
}
interface Callable { Object call() throws Exception; }
static String rel(Path base, Path p) {
String s = base.relativize(p).toString().replace(File.separatorChar, '/');
return s.isEmpty() ? "." : s;
}
static long size(Path p) {
try {
return Files.size(p);
} catch (IOException e) {
throw new UncheckedIOException(e); // lambdas can't throw checked exceptions
}
}
public static void main(String[] args) throws IOException {
Path root = Files.createTempDirectory("garden");
try {
run(root);
} finally {
try (Stream<Path> all = Files.walk(root)) { // deepest first, so directories are empty
for (Path p : all.sorted(Comparator.reverseOrder()).toList()) Files.delete(p);
}
}
}
static void run(Path root) throws IOException {
System.out.println("== 1. mark(), reset() and skip()");
byte[] cedar = "CEDAR".getBytes(StandardCharsets.US_ASCII);
Path cedarFile = Files.write(root.resolve("cedar.bin"), cedar);
System.out.println(" ByteArrayInputStream (mark supported): " + readWithMark(new ByteArrayInputStream(cedar)));
try (var in = new FileInputStream(cedarFile.toFile())) {
System.out.println(" FileInputStream (no mark support): " + readWithMark(in));
}
try (var in = new FileInputStream(cedarFile.toFile())) {
System.out.println(" FileInputStream.reset() anyway -> " + attempt(() -> { in.reset(); return "ok"; }));
}
try (var in = new BufferedInputStream(new FileInputStream(cedarFile.toFile()))) {
System.out.println(" ...wrapped in BufferedInputStream, markSupported(): " + in.markSupported());
}
var planet = new ByteArrayInputStream("PLANET".getBytes(StandardCharsets.US_ASCII));
var sb = new StringBuilder().append((char) planet.read()); // P
long skipped = planet.skip(2); // L, A
planet.read(); // N, read and thrown away
sb.append((char) planet.read()).append((char) planet.read()); // E, T
System.out.println(" PLANET with skip(2) and a discarded read: " + sb + " (skip returned " + skipped + ")");
System.out.println(" skip(1000) near the end returns only what was skipped: "
+ new ByteArrayInputStream("abc".getBytes(StandardCharsets.US_ASCII)).skip(1000));
var noMark = new ByteArrayInputStream("xyz".getBytes(StandardCharsets.US_ASCII));
noMark.read();
noMark.read();
noMark.reset(); // ByteArrayInputStream: mark defaults to 0
System.out.println(" ByteArrayInputStream.reset() without mark goes to the start: " + (char) noMark.read());
System.out.println(" BufferedReader.reset() without mark -> " + attempt(() -> {
var r = new BufferedReader(new StringReader("xyz"));
r.read();
r.reset();
return "ok";
}));
System.out.println(" BufferedReader read past its readLimit -> " + attempt(() -> {
var r = new BufferedReader(new StringReader("abcdefghij"), 2);
r.mark(2);
for (int i = 0; i < 5; i++) r.read();
r.reset();
return "ok";
}));
Files.delete(cedarFile);
System.out.println("\n== 2. Accessibility checks");
Path notes = Files.writeString(root.resolve("notes.txt"), "water the ferns");
Path secret = Files.writeString(root.resolve(".secret"), "pin 4821");
Path script = Files.writeString(root.resolve("water.sh"), "echo splash");
FileStore store = Files.getFileStore(root);
if (store.supportsFileAttributeView(DosFileAttributeView.class)) {
Files.setAttribute(secret, "dos:hidden", true); // Windows: hidden is an attribute
}
if (store.supportsFileAttributeView(PosixFileAttributeView.class)) {
Files.setPosixFilePermissions(script, PosixFilePermissions.fromString("rwxr-xr-x"));
}
Path missing = root.resolve("missing.txt");
System.out.println(" notes.txt readable=" + Files.isReadable(notes) + " writable=" + Files.isWritable(notes)
+ " hidden=" + Files.isHidden(notes));
System.out.println(" .secret hidden=" + Files.isHidden(secret));
System.out.println(" water.sh executable=" + Files.isExecutable(script));
System.out.println(" missing readable=" + Files.isReadable(missing) + " writable=" + Files.isWritable(missing)
+ " executable=" + Files.isExecutable(missing) + " (false, no exception)");
System.out.println("\n== 3. Reading all basic attributes at once, and changing one");
var view = Files.getFileAttributeView(notes, BasicFileAttributeView.class);
view.setTimes(FileTime.from(Instant.parse("2030-04-01T09:30:00Z")), null, null); // null = leave as is
BasicFileAttributes attrs = Files.readAttributes(notes, BasicFileAttributes.class);
System.out.println(" regular=" + attrs.isRegularFile() + " directory=" + attrs.isDirectory()
+ " link=" + attrs.isSymbolicLink() + " size=" + attrs.size());
System.out.println(" lastModifiedTime=" + attrs.lastModifiedTime());
System.out.println(" by name: " + new TreeMap<>(Files.readAttributes(notes, "size,isDirectory"))
+ ", getAttribute(\"basic:size\")=" + Files.getAttribute(notes, "basic:size"));
Files.delete(secret);
Files.delete(script);
System.out.println("\n== 4. Walking a tree (depth-first, lazy)");
Files.createDirectories(root.resolve("beds/herbs"));
Files.createDirectories(root.resolve("shed"));
Files.writeString(root.resolve("beds/roses.txt"), "prune in March");
Files.writeString(root.resolve("beds/herbs/basil.txt"), "pinch tops");
Files.writeString(root.resolve("beds/herbs/mint.java"), "class Mint { }");
Files.writeString(root.resolve("shed/tools.txt"), "rake");
try (Stream<Path> s = Files.walk(root)) {
System.out.println(" all: " + s.map(p -> rel(root, p)).sorted().toList());
}
try (Stream<Path> s = Files.walk(root, 1)) {
System.out.println(" depth 1: " + s.map(p -> rel(root, p)).sorted().toList());
}
try (Stream<Path> s = Files.walk(root, 0)) {
System.out.println(" depth 0: " + s.map(p -> rel(root, p)).toList());
}
try (Stream<Path> s = Files.walk(root)) {
List<Path> order = s.toList();
boolean parentsFirst = order.stream().allMatch(p -> p.equals(root) || order.indexOf(p.getParent()) < order.indexOf(p));
System.out.println(" every directory comes before its contents: " + parentsFirst);
}
try (Stream<Path> s = Files.walk(root)) {
long total = s.filter(Files::isRegularFile).mapToLong(Solution::size).sum();
System.out.println(" total size of all files: " + total + " bytes");
}
System.out.println("\n== 5. Symbolic links and cycles");
Path link = Files.createSymbolicLink(root.resolve("beds/herbs/back-to-beds"), root.resolve("beds"));
try (Stream<Path> s = Files.walk(root.resolve("beds"))) {
System.out.println(" default walk lists the link but doesn't enter it: "
+ s.map(p -> rel(root, p)).sorted().toList());
}
System.out.println(" isDirectory(link)=" + Files.isDirectory(link) + ", with NOFOLLOW_LINKS="
+ Files.isDirectory(link, LinkOption.NOFOLLOW_LINKS) + ", isSymbolicLink=" + Files.isSymbolicLink(link));
try (Stream<Path> s = Files.walk(root, FileVisitOption.FOLLOW_LINKS)) {
System.out.println(" walk with FOLLOW_LINKS counted " + s.count());
} catch (UncheckedIOException e) { // thrown while the stream is consumed
System.out.println(" walk with FOLLOW_LINKS -> UncheckedIOException, cause: "
+ e.getCause().getClass().getSimpleName());
}
Files.delete(link);
System.out.println("\n== 6. find() with a BiPredicate<Path, BasicFileAttributes>");
try (Stream<Path> s = Files.find(root, 10,
(p, a) -> a.isRegularFile() && p.toString().endsWith(".txt") && a.size() > 5)) {
System.out.println(" .txt files over 5 bytes: " + s.map(p -> rel(root, p)).sorted().toList());
}
try (Stream<Path> s = Files.find(root, 2, (p, a) -> a.isRegularFile())) {
System.out.println(" files within depth 2: " + s.map(p -> rel(root, p)).sorted().toList());
}
System.out.println("\n== 7. DirectoryStream with a glob (one directory, not recursive)");
try (DirectoryStream<Path> dir = Files.newDirectoryStream(root.resolve("beds/herbs"), "*.{txt,java}")) {
List<String> names = new ArrayList<>();
for (Path p : dir) names.add(p.getFileName().toString());
Collections.sort(names);
System.out.println(" matches: " + names);
System.out.println(" second iterator() -> " + attempt(dir::iterator));
}
}
}
Output:
== 1. mark(), reset() and skip()
ByteArrayInputStream (mark supported): CEDEDAR
FileInputStream (no mark support): CEDAR
FileInputStream.reset() anyway -> IOException (mark/reset not supported)
...wrapped in BufferedInputStream, markSupported(): true
PLANET with skip(2) and a discarded read: PET (skip returned 2)
skip(1000) near the end returns only what was skipped: 3
ByteArrayInputStream.reset() without mark goes to the start: x
BufferedReader.reset() without mark -> IOException (Stream not marked)
BufferedReader read past its readLimit -> IOException (Mark invalid)
== 2. Accessibility checks
notes.txt readable=true writable=true hidden=false
.secret hidden=true
water.sh executable=true
missing readable=false writable=false executable=false (false, no exception)
== 3. Reading all basic attributes at once, and changing one
regular=true directory=false link=false size=15
lastModifiedTime=2030-04-01T09:30:00Z
by name: {isDirectory=false, size=15}, getAttribute("basic:size")=15
== 4. Walking a tree (depth-first, lazy)
all: [., beds, beds/herbs, beds/herbs/basil.txt, beds/herbs/mint.java, beds/roses.txt, notes.txt, shed, shed/tools.txt]
depth 1: [., beds, notes.txt, shed]
depth 0: [.]
every directory comes before its contents: true
total size of all files: 57 bytes
== 5. Symbolic links and cycles
default walk lists the link but doesn't enter it: [beds, beds/herbs, beds/herbs/back-to-beds, beds/herbs/basil.txt, beds/herbs/mint.java, beds/roses.txt]
isDirectory(link)=true, with NOFOLLOW_LINKS=false, isSymbolicLink=true
walk with FOLLOW_LINKS -> UncheckedIOException, cause: FileSystemLoopException
== 6. find() with a BiPredicate<Path, BasicFileAttributes>
.txt files over 5 bytes: [beds/herbs/basil.txt, beds/roses.txt, notes.txt]
files within depth 2: [beds/roses.txt, notes.txt, shed/tools.txt]
== 7. DirectoryStream with a glob (one directory, not recursive)
matches: [basil.txt, mint.java]
second iterator() -> IllegalStateException (Iterator already obtained)
Points to notice:
CEDEDARandCEDARcome from the same method, and in both cases the stream ends at the end of the data. That's the reason to arrange reads aroundmarkSupported().- Wrapping the unsupported
FileInputStreamin aBufferedInputStreamaddsmarksupport. PLANETbecamePET:skip(2)removedLandAand returned 2, and an ignoredread()droppedN.missing.txtgivesfalsefor all three access checks, with no exception.- After
setTimes(..., null, null), only the last-modified time changed.readAttributesthen returned everything in one call. walk(root, 0)contains just the start, andwalk(root, 1)adds the direct children. In every walk a directory comes before its contents.- The default walk lists
back-to-bedsbut doesn't enter it.FOLLOW_LINKSfinds the cycle, and the error arrives as anUncheckedIOExceptionwhilecount()consumes the stream. findwith depth 2 can't seebasil.txt(depth 3). The size test excluded the 4-bytetools.txtfrom the first search.
Common questions
What's the difference between walk + filter and find?
They give the same results. find hands you the BasicFileAttributes already loaded and needs a depth. With walk you'd call Files.isRegularFile or Files.size yourself, and the second of those throws a checked exception inside the lambda.
Why does walk throw UncheckedIOException instead of IOException?
walk itself declares IOException, but that only covers opening the start path. Later errors happen inside Stream operations, which can't throw checked exceptions, so they're wrapped.
Does mark() on a FileInputStream throw?
No. InputStream.mark() does nothing by default, and the problem only shows up when you call reset(). Reader.mark(), on the other hand, throws IOException straight away for readers that don't support it.
Is walk's order guaranteed?
Only partly. A directory always comes before its contents, and the start always comes first. The order of siblings follows the file system, so sort the results when order matters.
Summary
mark(readLimit)/reset()replay buffered data on streams wheremarkSupported()istrue. On others,resetthrowsIOException.skip(n)returns the count actually skipped.isHidden(throwsIOException),isReadable,isWritableandisExecutabletest single properties. The last three returnfalsefor missing files.Files.readAttributes(path, BasicFileAttributes.class)reads everything at once.getFileAttributeView(..., BasicFileAttributeView.class)can also change times withsetTimes. Basic attributes work on every file system, and DOS and POSIX views are platform-specific.Files.walkis a lazy, depth-firstStream<Path>with optionalmaxDepth. It doesn't follow links unless givenFOLLOW_LINKS, and then cycles causeFileSystemLoopException.Files.find(start, maxDepth, BiPredicate<Path, BasicFileAttributes>)filters while it walks.DirectoryStreamis the older, one-level, iterate-onceIterable.
Practice quiz
Test yourself with the advanced files quiz: 10 exam-style questions with explanations.
You've finished Chapter 14. Check your understanding of the whole chapter with the Chapter 14 review quiz: 20 mixed questions on File and Path, Files operations, I/O streams, reading and writing, serialization, the console and walking directory trees.
Previous: Java Console and User Interaction: System.in, System.out, System.err and Console (OCP 21)
Next: Java 22 to 25: What's New After the OCP 21 Exam (1Z0-831)
Related reading
- Java Console and User Interaction: System.in, System.out, System.err and Console (OCP 21)
- Java Serialization: Serializable, transient, serialVersionUID and Records (OCP 21)
- Java Reading and Writing Files: I/O Streams, Buffered Readers and Files Methods (OCP 21)
- Java I/O Streams: Byte and Character, Input and Output, Low-Level and High-Level (OCP 21)
- Java Files: Copying, Moving, Deleting and Comparing Files (OCP 21)

More in OCP Java 21
OCP Java 21 Mock Exam 3 (1Z0-830)
The third full 50-question mock exam for the OCP Java SE 21 Developer exam (1Z0-830), weighted toward the hardest areas: streams, concurrency, generics, modules and I/O. 120 minutes, 68% to pass, with explanations.
OCP Java 21 Mock Exam 2 (1Z0-830)
The second full 50-question mock exam for the OCP Java SE 21 Developer exam (1Z0-830): new questions on every objective, with more multi-select. 120 minutes, 68% to pass, with an explanation for every answer.
OCP Java 21 Mock Exam 1 (1Z0-830)
A full 50-question mock exam for the OCP Java SE 21 Developer exam (1Z0-830), covering every objective at exam difficulty. 120 minutes, 68% to pass, with an explanation for every answer.
Quiz: Final Review (OCP 21)
Ten exam-style questions mixing the most-tested OCP Java 21 rules from the final checklist: promotion, String immutability, overloading, initialization order, collections, streams, exceptions and switch patterns, with explanations.
Discussion
Sign in to ask a question or share what you learned.