IT Certifications · 1Z0-808

Oracle Java SE 8 Programmer I (also available in CHS for Taiwan) Exam Practice Test

Oracle Java SE 8 Programmer I practice focuses on reading and reasoning about Java code: declarations, expressions, control flow, arrays, and strings. The available question bank includes tasks such as tracing loop and switch behavior, evaluating string methods, recognizing a valid entry-point signature, and identifying compile-time errors or runtime exceptions.

Exam overview

Exam providerOracle
Exam code1Z0-808
CategoryIT Certifications

About the Oracle Java SE 8 Programmer I (also available in CHS for Taiwan) Exam

Preparation involves tracking how Java evaluates expressions and executes statements, then distinguishing outcomes that depend on scope, initialization, and control flow. Practice interpreting array declarations and indexing, comparing strings, and following methods such as `substring` and `charAt`, including their argument boundaries. Be able to identify when local variables need initialization, where loop variables are accessible, and why dereferencing `null` causes a runtime exception. For branching code, trace each matching `switch` case and determine whether `break` prevents fall-through. These skills support writing, debugging, and reviewing basic Java SE programs by predicting output, spotting invalid code, and explaining the difference between compilation failures and runtime behavior.

Sample Practice Questions

Review a selection from this exam's published US Practice Tests practice bank.

Question 1

Which statement about a `while` loop is correct?

  1. AIts condition is checked after every iteration only.
  2. BIts body executes at least once.
  3. CIts condition is checked before each iteration, so the body may execute zero times.
  4. DIt can be used only with integer conditions.
Show answerCorrect answer: C

A `while` loop evaluates its boolean condition before entering the body. If the condition is initially false, the body does not run.

Question 2

What is the result of evaluating `"pear".compareTo("peach")` in Java?

  1. AA negative integer
  2. BZero
  3. CA positive integer
  4. DA boolean value
Show answerCorrect answer: A

`String.compareTo` compares strings lexicographically. The first differing characters are `a` in `pear` and `a` in `peach`, followed by `r` and `c`; since `r` is greater than `c`, this particular comparison is positive. Wait: compare from the beginning: `p`=`p`, `e`=`e`, then `a`=`a`, then `r` versus `c`; `r` is greater, so the result is a positive integer.

Question 3

Which declaration creates a two-dimensional array with two rows, where each row initially contains three `int` elements?

  1. A`int[][] grid = new int[2][3];`
  2. B`int[2][3] grid = new int[][];`
  3. C`int[][] grid = new int[3][2];`
  4. D`int[] grid = new int[2][3];`
Show answerCorrect answer: A

The declaration `new int[2][3]` creates an array with two rows, each containing three integer elements. Java places the array brackets with the type, not after the variable name in this form.

Question 4

What does this code print? `System.out.println("Hello".substring(1, 4));`

  1. AHel
  2. Bell
  3. Cello
  4. DHello
Show answerCorrect answer: B

`substring(begin, end)` includes the character at the beginning index and excludes the character at the end index. Indices 1 through 3 contain `ell`.

Question 5

What happens when this method is compiled? `static void show() { int value; System.out.println(value); }`

  1. AIt compiles and prints `0`.
  2. BIt compiles and prints `null`.
  3. CIt fails to compile because the local variable may not have been initialized.
  4. DIt fails at runtime with `NullPointerException`.
Show answerCorrect answer: C

Local variables do not receive default values. Java requires a local variable to be definitely assigned before it is read, so this method does not compile.

Question 6

What does this code print? `String word = "sun"; System.out.println(word.charAt(1));`

  1. A`s`
  2. B`u`
  3. C`n`
  4. DIt throws an exception.
Show answerCorrect answer: B

String indices start at 0. In `"sun"`, index 0 is `s`, index 1 is `u`, and index 2 is `n`.

Question 7

Which declaration is a valid Java entry-point method signature?

  1. A`public static void main(String[] args)`
  2. B`public void main(String[] args)`
  3. C`static int main(String[] args)`
  4. D`public static main(String[] args)`
Show answerCorrect answer: A

The conventional Java application entry point is `public static void main(String[] args)`: it is public and static, returns `void`, and accepts a `String` array.

How to use this practice test

Access is free. A session presents up to 20 random questions from the 50-question bank and shows results afterward. Use each result to identify code-reading gaps, then revisit the relevant Java construct by tracing a small example and explaining its compile-time or runtime behavior.

Preparation tips

  • Trace `while` and `for` loops one iteration at a time, recording condition values and updates to avoid off-by-one errors.
  • For `switch` statements, mark the selected case and follow execution through each subsequent statement until a `break` or the end of the switch.
  • Check string method arguments carefully: `substring` uses a start index and exclusive end index, while `charAt` requires a valid single index.
  • For array declarations, count rows and elements per row; distinguish an initialized two-dimensional array from an array whose rows are not yet created.
  • Classify code problems as compile-time errors or runtime exceptions, especially for uninitialized local variables and method calls on `null`.
Official sourceOfficial exam page ↗