Oracle Java SE 25 Developer Professional Exam Practice Test
The Oracle Java SE 25 Developer Professional Exam practice page centers on interpreting Java code and predicting its behavior. The available questions sample packages, arrays, integer arithmetic, loops, exception handling, `HashMap`, interface default methods, `Optional`, and `switch` expressions. These topics call for precise reasoning about types, references, library methods, and control flow.
Exam overview
About the Oracle Java SE 25 Developer Professional Exam
Java development requires more than recognizing syntax: developers must determine which declarations are accessible, how objects and arrays behave when referenced from multiple variables, and which branch or handler runs. Practice with collection and API questions by checking the contracts of types such as `HashMap` and `Optional`, including how null values affect results. For code-tracing problems, evaluate expressions using Java’s type rules, follow loop updates in order, and distinguish array length from string length. Questions involving interface default methods and `switch` expressions also reward careful attention to compile-time rules and returned values. Building these habits supports debugging, code review, and implementation decisions where a small difference in evaluation order or API behavior changes the result.
Sample Practice Questions
Review a selection from this exam's published US Practice Tests practice bank.
Which statement about Java packages is correct?
Show answer
Correct answer: AA package declaration, if included, precedes import declarations and top-level type declarations. A source file may omit a package declaration, and package declarations do not appear inside class bodies.
What is the value of `first` after this code runs? `int first = 0; try { int[] numbers = {6, 8}; first = numbers[1]; } catch (ArrayIndexOutOfBoundsException ex) { first = -1; }`
Show answer
Correct answer: DArray indexing starts at 0, so `numbers[1]` refers to the second element, 8. No exception is thrown, and the catch block does not execute.
Which statement about a `HashMap` is correct?
Show answer
Correct answer: BA `HashMap` permits a single `null` key and any number of `null` values. It does not guarantee insertion-order iteration or sort its entries.
Which statement about an interface's default method is correct?
Show answer
Correct answer: AAn interface default method has an implementation, introduced with the `default` keyword, and implementing classes can inherit it or provide an override.
What is the value of `length` after this code runs? `String[] names = new String[3]; int length = names.length;`
Show answer
Correct answer: CAn array's `length` is fixed when it is created. This array has three slots; reference elements are initialized to `null`, which does not prevent reading its length.
What is the result of evaluating `Optional.ofNullable(null).isEmpty()`?
Show answer
Correct answer: A`Optional.ofNullable(null)` produces an empty `Optional`. Its `isEmpty()` method therefore returns `true`.
What is printed by this code? `int[] values = {2, 4}; int[] alias = values; alias[0] = 9; System.out.println(values[0]);`
Show answer
Correct answer: CAn array variable holds a reference to an array object. Assigning `values` to `alias` copies that reference, so both variables refer to the same array. Updating an element through `alias` is visible through `values`.
How to use this practice test
Access is free. Each session draws up to 20 random questions from the available bank of 50 and displays results afterward. Use a session to identify code-tracing errors, then revisit the relevant Java rule—such as array references, integer division, exception flow, or `Optional` behavior—before trying another set.
Preparation tips
- Trace array assignments and mutations separately: note whether a statement changes an array element or only reassigns a reference.
- Evaluate expressions using Java’s declared types; for integer arithmetic, calculate division before assigning the result to an `int`.
- For exception questions, follow statements in order and identify whether an exception is thrown before the `catch` block can run.
- Compare API behavior precisely: check `HashMap` key and value rules, and distinguish `Optional.ofNullable(null)` from `Optional.of(...)`.
- For interface and `switch` questions, inspect method declarations, branch labels, and whether each expression path produces a compatible result.