1z0-809 Sample Questions & Answers
Spans lambda expressions and built-in functional interfaces tied with Stream API operations, generics and collections, advanced class design using abstract and inner classes, exceptions and assertions, the Date and Time API, file I/O, concurrency, JDBC and localization.
Launch the full 1z0-809 simulator →Showing 10 of 20 free samples.
- Question 1
Given:
public class Counter {
public static void main (String[ ] args) {
int a = 10;
int b = -1;
assert (b )=1) : “Invalid Denominator';
int = a / b;
System.out.println (c);
}
}
What is the result of running the code with the -ea option?
Show answer & explanation
Correct answer: C
C
- Question 2
Given:
class Bird {
public void fly () { System.out.print(“Can fly'); }
}
class Penguin extends Bird {
public void fly () { System.out.print(“Cannot fly'); }
}
and the code fragment:
class Birdie {
public static void main (String [ ] args) {
fly( ( ) -) new Bird ( ));
fly (Penguin : : new);
}
/* line n1 */
}
Which code fragment, when inserted at line n1, enables the Birdie class to compile?
Show answer & explanation
Correct answer: C
C
- Question 3Select 2
Given:
abstract class Shape {
Shape ( ) { System.out.println (“Shape'); }
protected void area ( ) { System.out.println (“Shape'); }
}
class Square extends Shape {
int side;
Square int side {
/* insert code here */
this.side = side;
}
public void area ( ) { System.out.println (“Square'); }
}
class Rectangle extends Square {
int len, br;
Rectangle (int x, int y) {
/* insert code here */
len = x, br = y;
}
void area ( ) { System.out.println (“Rectangle'); }
}
Which two modifications enable the code to compile? (Choose two.)
Show answer & explanation
Correct answers: D, F
D,F
D,F
- Question 4
Given:
class Sum extends RecursiveAction { //line n1 static final int THRESHOLD_SIZE = 3;
int stIndex, lstIndex;
int [ ] data;
public Sum (int [ ]data, int start, int end) {
this.data = data;
this stIndex = start;
this. lstIndex = end;
}
protected void compute ( ) {
int sum = 0;
if (IstIndex - stIndex (= THRESHOLD_SIZE) {
for (int i = stIndex; i ( lstIndex; i++) {
sum += data [i];
}
System.out.println(sum);
} else {
new Sum (data, stIndex + THRESHOLD_SIZE, lstIndex).fork( );
new Sum (data, stIndex,
Math.min (lstIndex, stIndex + THRESHOLD_SIZE)
).compute ();
}
}
}
and the code fragment:
ForkJoinPool fjPool = new ForkJoinPool ( );
int data [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fjPool.invoke (new Sum (data, 0, data.length));
and given that the sum of all integers from 1 to 10 is 55.
Which statement is true?Show answer & explanation
Correct answer: A
A
- Question 5
Given the content of Operator.java, EngineOperator.java, and Engine.java files:
What is the result?

Show answer & explanation
Correct answer: A
A
- Question 6
Given the code fragment:
Stream(List(String)) iStr= Stream.of (
Arrays.asList (“1', “John'),
Arrays.asList (“2', null));
Stream((String) nInSt = iStr.flatMapToInt ((x) -) x.stream ());
nInSt.forEach (System.out :: print);
What is the result?
Show answer & explanation
Correct answer: D
D
- Question 7
Given the code fragment:
Path file = Paths.get (“courses.txt');
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
Show answer & explanation
Correct answer: D
D
- Question 8
Given the code fragment:
public void recDelete (String dirName) throws IOException {
File [ ] listOfFiles = new File (dirName) .listFiles();
if (listOfFiles ! = nulllistOfFiles.length )0) {
for (File aFile : listOfFiles) {
if (aFile.isDirectory ()) {
recDelete (aFile.getAbsolutePath ());
} else {
if (aFile.getName ().endsWith (“.class'))
Oracle 1z0-809 Exam aFile.delete ();
}
}
}
}
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.
What is the result?
Show answer & explanation
Correct answer: A
A
- Question 9
Given the code fragments:
void doStuff() throws ArithmeticException, NumberFormatException, Exception {
if (Math.random() )-1 throw new Exception (“Try again');
}
and
try {
doStuff ( ):
} catch (ArithmeticException | NumberFormatException | Exception e) {
System.out.println (e.getMessage()); }
catch (Exception e) {
System.out.println (e.getMessage()); }
}
Which modification enables the code to print Try again?
Show answer & explanation
Correct answer: C
C
- Question 10
Given the definition of the Country class:
public class country {
public enum Continent {ASIA, EUROPE}
String name;
Continent region;
public Country (String na, Continent reg) {
name = na, region = reg;
}
public String getName () {return name;}
public Continent getRegion () {return region;}
}
and the code fragment:
List(Country) couList = Arrays.asList (
new Country (“Japan', Country.
Continent.
ASIA),
new Country (“Italy', Country.
Continent.
EUROPE),
new Country (“Germany', Country.
Continent.
EUROPE));
Map(Country.
Continent, List(String)) regionNames = couList.stream ()
.collect(Collectors.groupingBy (Country ::getRegion,
Collectors.mapping(Country::getName, Collectors.toList()))));
System.out.println(regionNames);
What is the output?
Show answer & explanation
Correct answer: B
B
Ready for the real thing?
The full 1z0-809 simulator has every exam-style question, timed mode, and instant scoring.