Browse Oracle Certification Guides

Java 17 1Z0-829 Sample Questions with Explanations

Java 17 1Z0-829 sample questions with explanations, traps, topic labels, and IT Mastery route links.

These original sample questions are designed to help you check how the exam topics appear in decision-style prompts. They are not taken from the live exam.

Use these sample questions as a guided self-assessment for Oracle Java SE 17 Developer (1Z0-829) topics such as overload resolution, sealed classes, records, streams, modules, collections, exceptions, and exact code-reading behavior. The prompts are deliberately compact: the hard part is deciding whether the code compiles, which rule applies first, and what the runtime contract actually says.

Where these questions fit in the 1Z0-829 guide

The sample set below is part of the Oracle Java 1Z0-829 guide path:

1Z0-829 Java code-reading sample questions

Work through each prompt before opening the explanation. For Java professional questions, decide whether the code compiles before predicting output.


Question 1

Topic: Overload resolution with null

What is the result of compiling and running this code?

1static void print(Object value) {
2    System.out.print("object");
3}
4static void print(String value) {
5    System.out.print("string");
6}
7public static void main(String[] args) {
8    print(null);
9}
  • A. It prints object.
  • B. It does not compile because null has no type.
  • C. It prints string.
  • D. It compiles but throws NullPointerException.

Best answer: C

Explanation: Both overloads are applicable for null, but String is more specific than Object, so the String overload is selected.

Why the other choices are weaker:

  • A ignores the most-specific overload rule.
  • B is wrong because null can be passed to reference-typed parameters.
  • D predicts a runtime failure, but the selected method only prints text.

What this tests: Overload resolution, reference typing, and the compile-first habit.

Related topics: Overloading; Null; Method resolution; Compilation


Question 2

Topic: Sealed hierarchy legality

Which statement about this code is correct?

1sealed interface Device permits Phone, Tablet {}
2final class Phone implements Device {}
3class Tablet implements Device {}
  • A. The code compiles because Tablet is listed in the permits clause.
  • B. The code does not compile because sealed interfaces cannot permit classes.
  • C. The code does not compile because Tablet must be declared final, sealed, or non-sealed.
  • D. The code compiles only if Device is changed to an abstract class.

Best answer: C

Explanation: A direct subtype of a sealed type must explicitly choose how the hierarchy continues: final, sealed, or non-sealed. Listing Tablet in permits is necessary, but not sufficient.

Why the other choices are weaker:

  • A misses the modifier requirement on permitted subclasses.
  • B is false; classes can implement sealed interfaces.
  • D changes the design unnecessarily and does not address the actual rule.

What this tests: Sealed type declarations and permitted-subtype obligations.

Related topics: Sealed types; Interfaces; Inheritance; Modifiers


Question 3

Topic: Optional and eager fallback work

What is printed by this code?

1static String fallback() {
2    System.out.print("fallback ");
3    return "guest";
4}
5public static void main(String[] args) {
6    var name = java.util.Optional.of("admin").orElse(fallback());
7    System.out.print(name);
8}
  • A. admin
  • B. fallback guest
  • C. The code does not compile because orElse cannot call a method.
  • D. fallback admin

Best answer: D

Explanation: The argument to orElse is evaluated before the method call, even when the Optional contains a value. The fallback method prints first, but orElse returns the contained "admin".

Why the other choices are weaker:

  • A confuses orElse with lazy fallback behavior.
  • B assumes the fallback return value replaces the present value.
  • C invents a restriction; method calls are valid expressions.

What this tests: Optional fallback evaluation and side-effect ordering.

Related topics: Optional; Evaluation order; Method calls; Runtime output

Independent study note

Tech Exam Lexicon and IT Mastery are independent study tools. They are not affiliated with, endorsed by, or sponsored by Oracle or any certification body.

Revised on Sunday, May 10, 2026