Skip to content

50 questions · 90 minutes · 68% to pass Format from secondary sources: check it on education.oracle.com before you book.

Exam 1Z0-829 · Java SE 17 Developer

Learn OCP 17 one rule at a time, with answers run on JDK 17.

The OCP 17 syllabus is split into short drills, one rule each: 1,293 so far. Answer one, see what JDK 17 did, and it comes back just before you'd forget it. You learn by recalling each rule, not by rereading a book.

1,293 drills · 11 domains · 94 topics · every code answer run on JDK 17

9.3.1Path operations: resolve, relativize, normalizeJDK 17

Press 1 to 3 to choose an answer

What happens?

Main.java
void main() {    Path p = Path.of("a/b/c/d");    Path s = p.subpath(1, 3);    IO.println(s.getNameCount() + " " + s.getFileName());}

How does java Main.java end?
  • One rule per drill

    Each drill tests one rule, so a miss tells you exactly what to fix.

  • The JVM decides, not us

    Compile errors, exceptions, and output are captured from real runs.

  • Back before you forget

    Missed drills come back sooner. The ones you know come back less often.

Short drills, one rule each

A study guide explains a topic like this one once, in a few pages. Here it becomes 19 short drills on 14 rules, each answered in seconds and each brought back on its own schedule. Below are 6 of them, with what JDK 17 did.

9.3.1Path operations: resolve, relativize, normalize19 drills on 14 rules, run on JDK 17
  • Prints output: 13
  • Compile error: 2
  • Runtime exception: 4
  • Main.java
    void main() {    Path p = Path.of("a/b/..");    IO.println(p.getFileName() + " " + p.normalize().getFileName());}

    Prints output
    $ java Main.java.. a

    RulegetFileName() of a/b/.. is .. — nothing is normalized automatically.

  • Main.java
    void main() {    Path p = new Path("a/b");    IO.println(p.getNameCount());}

    Line 2 is highlighted.

    Compile error
    $ java Main.javaMain.java:2: error: Path is abstract; cannot be instantiated    Path p = new Path("a/b");             ^error: compilation failed

    RulePath is an interface: create with Path.of(first, more…) (legacy Paths.get), never new. Path.of rejects illegal characters with InvalidPathException.

  • Main.java
    void main() {    Path p = Path.of("a/b/c");    IO.println(p.getName(0) + " " + p.getName(3));}

    Runtime exception
    $ java Main.javaException in thread "main" java.lang.IllegalArgumentException

    Rulesubpath(1, 5) on a 4-element path and getName(3) on a 3-element path throw IllegalArgumentException.

  • Main.java
    void main() {    Path from = Path.of("a/b");    Path to = Path.of("a/c/d");    IO.println(from.relativize(to).equals(Path.of("../c/d")));}

    Prints output
    $ java Main.javatrue

    Rulerelativize(q): path from this to q (a/b → a/c/d = ../c/d); mixing relative and absolute → IllegalArgumentException.

  • Main.java
    void main() throws IOException {    Path p = Path.of("drafts", "q3", "plan.md");    Path real = p.toRealPath();    IO.println(real.isAbsolute() + " " + real.getFileName());}

    Runtime exception
    $ java Main.javaException in thread "main" java.nio.file.NoSuchFileException: drafts/q3/plan.md

    RuletoRealPath() needs the file to exist; toAbsolutePath() does not.

  • Main.java
    void main() {    Path p = Path.of("abc/def");    IO.println(p.startsWith("ab") + " " + p.startsWith("abc"));}

    Prints output
    $ java Main.javafalse true

    RulePath.of("abc/def").startsWith("ab") is false.

A one-page recap for every topic

Every topic has one, written for the drills it supports. It opens with the main idea, the line to remember, the traps, and a diagram. The rest is one click away. This one covers the topic of the drills above.

9.3.1Path operations: resolve, relativize, normalizeRecap

A Path is an immutable, purely syntactic list of name elements (plus an optional root); almost all Path methods just manipulate that list and never touch the disk.

Remember Path = list of names. Only toRealPath looks at the disk.

Traps

  • subpath(1, 5) on a 4-element path and getName(3) on a 3-element path throw IllegalArgumentException.
  • getFileName() of a/b/.. is .. — nothing is normalized automatically.
  • normalize() keeps a leading ...
  • resolve with an absolute argument ignores the receiver.
  • toRealPath() needs the file to exist; toAbsolutePath() does not.
  • Path.of("abc/def").startsWith("ab") is false.
Path methods
MethodExampleResultTouches disk?
getFileName()a/b/cc
getParent()a/b/c · ca/b · null
getRoot()a/bnull
getName(1)a/b/cb (index 3 → IAE)
subpath(1,3)a/b/c/db/c (end exclusive)
normalize()a/./b/../c · ../x/./ya/c · ../x/y
resolve(q)a/b + c · + /absa/b/c · /abs
resolveSibling(q)a/b/c.txt + d.txta/b/d.txt
relativize(q)a/b → a/c/d../c/d (mixed kinds → IAE)
toAbsolutePath()a/bcwd + a/b
toRealPath()missing fileNoSuchFileException

Learn first, then rehearse

The OCP 17 syllabus is long. A study guide covers it once, in prose. A full mock exam tests it all at once: each question mixes several traps and topics, and one sitting takes about two hours. Learn here first, one rule at a time, then rehearse under exam conditions.

  1. In this app

    Learn one rule at a time

    Short daily sessions. Each drill tests one rule, shows what the JVM did, and comes back just before you'd forget it.

  2. In this app

    Check readiness by domain

    Recall per domain shows which objectives you still miss, so you study those instead of rereading everything.

  3. With full mock exams, such as Enthuware

    Rehearse under exam conditions

    Full timed mock exams: long code, mixed traps, the clock. Enthuware is built for this. The few mock exams here check your timing. They don't replace a full bank.

  • Study guide

    One sitting
    A chapter
    Rules per question
    Many, explained in prose
    When you find out you were wrong
    When you test yourself
    When it comes back
    When you reread it
    Best for
    A first complete pass over the syllabus
  • Short drills, here

    One sitting
    As long as you have: stop after any drill
    Rules per question
    One
    When you find out you were wrong
    Right after you answer, with the JVM output
    When it comes back
    Just before you'd forget it
    Best for
    Learning each rule until it sticks
  • Full mock exam

    One sitting
    50 questions in 90 minutes Format from secondary sources: check it on education.oracle.com before you book.
    Rules per question
    Several, across topics
    When you find out you were wrong
    After you submit the whole exam
    When it comes back
    On your next mock exam
    Best for
    Rehearsing the exam before you book it

The OCP 17 syllabus, mapped

11 domains, each with its own drills, recap, and review schedule. Pick one to see what it covers.

Domain 1

Values, text & time

Handling date, time, text, numeric and boolean values

  • 1.1Primitives, wrappers & expressions
  • 1.2String, text blocks & StringBuilder
  • 1.3Date-Time API

17 topics in OCP 17

1Values, text & time2Program flow3Object-oriented Java4Exceptions5Arrays & collections6Streams & lambdas7Packaging & modules8Concurrency9I/O & NIO.210Databases (JDBC)11Localization
  • Values, text & time92%
  • Program flow84%
  • Object-oriented Java71%
  • Exceptions88%
  • Arrays & collections66%
  • Streams & lambdas58%
  • Packaging & modules79%
  • Concurrency62%
  • I/O & NIO.274%
  • Databases (JDBC)55%
  • Localization81%
Example learner, not real dataTarget 80%

Know when you're ready, domain by domain

Readiness is your predicted recall on each OCP 17 domain, not a single opaque score. Book the exam when every bar passes your target.

Same code, another Java version, another answer

Switching exams? Drills whose outcome changes between Java 17, 21, and 25 are marked as version traps. Pick a JDK to see what it did with this one.

Main.java
enum Light { RED, AMBER, GREEN }void main() {    Light l = Light.GREEN;    String action = switch (l) {        case Light.RED -> "stop";        case AMBER, GREEN -> "go";    };    IO.println(action);}

Captured run

Run on JDK 17

Compile errorExit code 1
$ java Main.javaMain.java:5: error: an enum switch case label must be the unqualified name of an enumeration constant        case Light.RED -> "stop";                  ^error: compilation failed

A few mock exams in the OCP 17 format

50 questions · 90 minutes · 68% to pass. Once you've learned the rules, use them to check your timing and find the domains that still cost you points. They don't replace a full mock-exam bank for rehearsal.

Format from secondary sources: check it on education.oracle.com before you book.

Example of the mock exam screen

Start free. Pay once it's working for you.

Prices in euros, VAT included. One pass covers every Java OCP exam: OCP 17, 21, and 25.

  • Free

    €0

    About 15% of each exam's drills, with the proof and the review schedule.

    Start free
  • Practice pass

    €24 for 120 days

    Every drill, recap and mock exam for the Java OCP exams.

    Get the practice pass
  • Course + practice

    €39 for 120 days

    The full course, lesson by lesson, plus the practice pass.

    Get the course
  • All-access

    €99 per year

    Every certification as it launches, courses and practice included.

    Get all-access

Questions

Do I still need full mock exams?

Yes. This app is for learning the rules, one at a time. Before you book OCP 17, rehearse with Enthuware’s full timed mock exams. They train you for the length, the mixed traps, and the clock.

Are these real exam questions?

No, and we never say they are. Every drill is original, written from the public OCP 17 objectives, the Java Language Specification, and the Javadoc.

How do you know the answers are right?

Each code drill is compiled and run on the JDK of every exam it applies to. The answer is what the JVM did, and you see its output.

Which exam should I take: OCP 17, 21 or 25?

The one that matches the Java your team runs. The syllabi differ: Java 17 still includes JDBC, and Java 25 adds module imports and compact source files. The app shows which drills apply to yours.

About 194 drills free on OCP 17. No card needed.

Try it free