IT Certifications · 1Z0-809

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

Exam providerOracle
Exam code1Z0-809
CategoryIT Certifications

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.

Question 1

Which statement describes `java.time.LocalDate`?

  1. AIt represents a date and time with a time zone.
  2. BIt represents a date without a time or time zone.
  3. CIt represents an elapsed duration measured in seconds.
  4. DIt represents a time of day without a date.
Show answerCorrect 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.

Question 2

Which statement about a `static` nested class is correct?

  1. AIt can directly access instance fields of the enclosing class without an enclosing instance.
  2. BIt must be declared inside a static method.
  3. CIt can be instantiated without first creating an instance of the enclosing class.
  4. DIt is implicitly an inner class with a reference to an enclosing instance.
Show answerCorrect answer: C

A 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.

Question 3

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);`

  1. A5
  2. B8
  3. C10
  4. DThe code does not compile.
Show answerCorrect answer: C

The assignment to 8 happens before the exception is thrown. The catch block then adds 2, so the printed value is 10.

Question 4

A class declares `private static int count;`. Which statement about `count` is correct?

  1. AEach instance has its own copy of `count`.
  2. BAll instances of the class share one `count` field.
  3. CThe field is initialized separately each time a method is called.
  4. DA static field cannot be accessed from a static method.
Show answerCorrect answer: B

A 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.

Question 5

Which statement about `StringBuilder` is correct?

  1. AIts contents cannot be changed after construction.
  2. BIt is mutable, so appending text can change the same builder object's contents.
  3. CIt automatically synchronizes every method for thread-safe access.
  4. DIt stores its contents as a `char[]` that callers can access directly through a public field.
Show answerCorrect 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.

Question 6

What is the value of `formatted`? `String formatted = String.format("%s-%02d", "item", 7);`

  1. Aitem-7
  2. Bitem-07
  3. Citem-007
  4. DCompilation fails because `%d` cannot format an integer.
Show answerCorrect 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`.

Question 7

Which statement describes `Optional.orElseGet(supplier)` when the optional contains a value?

  1. AIt always invokes the supplier and then discards its result.
  2. BIt returns the contained value and does not invoke the supplier.
  3. CIt throws `NoSuchElementException` because the supplier is not a value.
  4. DIt returns `null` unless the supplier produces a non-null value.
Show answerCorrect 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.
Official sourceOfficial exam page ↗