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.
The sample set below is part of the Oracle Java 1Z0-829 guide path:
Work through each prompt before opening the explanation. For Java professional questions, decide whether the code compiles before predicting output.
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}
object.null has no type.string.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:
null can be passed to reference-typed parameters.What this tests: Overload resolution, reference typing, and the compile-first habit.
Related topics: Overloading; Null; Method resolution; Compilation
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 {}
Tablet is listed in the permits clause.Tablet must be declared final, sealed, or non-sealed.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:
What this tests: Sealed type declarations and permitted-subtype obligations.
Related topics: Sealed types; Interfaces; Inheritance; Modifiers
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}
adminfallback guestorElse cannot call a method.fallback adminBest 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:
orElse with lazy fallback behavior.What this tests: Optional fallback evaluation and side-effect ordering.
Related topics: Optional; Evaluation order; Method calls; Runtime output
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.