Oracle Java SE 8 Programmer II (also available in CHS for Taiwan) Exam Practice Test
The Oracle Java SE 8 Programmer II practice page centers on object-oriented Java code and the behavior of standard language and library features. Its question bank samples topics such as nested classes, static fields, exception handling, strings, `Optional`, interface default methods, deprecation, date handling with `LocalDate`, and ordered collections such as `TreeSet`.
Exam overview
About the Oracle Java SE 8 Programmer II (also available in CHS for Taiwan) Exam
Java SE 8 programming work requires tracing how declarations, control flow, and library calls affect program behavior. Practice with code snippets by following variable updates through `try` and `catch` blocks, distinguishing class-level state from instance state, and checking how formatting directives affect strings. For collection questions, reason about ordering and uniqueness under a set’s comparator or natural ordering. For API questions, identify what `Optional` methods do when a value is present, how `LocalDate` represents calendar dates, and where interface default methods fit into type behavior. These skills help developers interpret existing code, select suitable Java APIs, and avoid errors when implementing or maintaining applications. Pay attention to exact method contracts and language rules rather than relying on names or assumptions.
Sample Practice Questions
Review a selection from this exam's published US Practice Tests practice bank.
Which statement describes `java.time.LocalDate`?
Show answer
Correct answer: B`LocalDate` stores a calendar date, such as a year, month, and day. It does not contain a time of day or time-zone information.
Which statement about a `static` nested class is correct?
Show answer
Correct answer: CA static nested class does not require an instance of its enclosing class for creation. It cannot directly access the enclosing class's instance members without an enclosing instance.
What is the output of this code? `int value = 5; try { value = 8; throw new IllegalStateException(); } catch (IllegalStateException e) { value += 2; } System.out.println(value);`
Show answer
Correct answer: CThe assignment to 8 happens before the exception is thrown. The catch block then adds 2, so the printed value is 10.
A class declares `private static int count;`. Which statement about `count` is correct?
Show answer
Correct answer: BA static field belongs to the class rather than to individual objects, so all instances share the same field. Its default value is zero for an `int` unless explicitly initialized.
Which statement about `StringBuilder` is correct?
Show answer
Correct answer: B`StringBuilder` is a mutable character sequence. Methods such as `append` modify the builder's contents; unlike `StringBuffer`, its methods are not generally synchronized.
What is the value of `formatted`? `String formatted = String.format("%s-%02d", "item", 7);`
Show answer
Correct answer: B`%s` formats the string argument. `%02d` formats an integer in a field at least two characters wide, padding on the left with zero, so the result is `item-07`.
Which statement describes `Optional.orElseGet(supplier)` when the optional contains a value?
Show answer
Correct answer: B`orElseGet` invokes its supplier only when the `Optional` is empty. If a value is present, that value is returned directly and the supplier is not evaluated.
How to use this practice test
Access is free. When the bank has published questions, a session presents up to 20 random questions from the 50-question bank and displays results afterward. Use each session to identify which Java behaviors need closer attention, then revisit the relevant code rules and API contracts.
Preparation tips
- Trace exception-handling snippets line by line, recording assignments made before a throw and inside each matching `catch` block.
- Compare static fields and nested classes with instance members; note which state or enclosing-instance access each declaration permits.
- Write small examples for `String.format` conversion and width specifiers, then verify the resulting characters and padding.
- Contrast `Optional.orElse` with `orElseGet` by checking when the fallback expression or supplier is evaluated.
- Practice collection behavior with `TreeSet`, including natural ordering, duplicate removal, and the effect of a custom comparator.