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
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.
Which statement about a `while` loop is correct?
Show answer
Correct answer: CA `while` loop evaluates its boolean condition before entering the body. If the condition is initially false, the body does not run.
What is the result of evaluating `"pear".compareTo("peach")` in Java?
Show answer
Correct 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.
Which declaration creates a two-dimensional array with two rows, where each row initially contains three `int` elements?
Show answer
Correct answer: AThe 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.
What does this code print? `System.out.println("Hello".substring(1, 4));`
Show answer
Correct 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`.
What happens when this method is compiled? `static void show() { int value; System.out.println(value); }`
Show answer
Correct answer: CLocal 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.
What does this code print? `String word = "sun"; System.out.println(word.charAt(1));`
Show answer
Correct answer: BString indices start at 0. In `"sun"`, index 0 is `s`, index 1 is `u`, and index 2 is `n`.
Which declaration is a valid Java entry-point method signature?
Show answer
Correct answer: AThe 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`.