Act now and download your Oracle 1Z0-809 test today! Do not waste time for the worthless Oracle 1Z0-809 tutorials. Download Renewal Oracle Java SE 8 Programmer II exam with real questions and answers and begin to learn Oracle 1Z0-809 with a classic professional.

2021 Dec 1Z0-809 test engine

Q21. Given the code fragments: 

public class Book implements Comparator<Book> { 

String name; 

double price; 

public Book () {} 

public Book(String name, double price) { = name; 

this.price = price; 

public int compare(Book b1, Book b2) { 


public String toString() { 

return name + “:” + price; 


List<Book>books = Arrays.asList (new Book (“Beginning with Java”, 2), new book (“A 

Guide to Java Tour”, 3)); 

Collections.sort(books, new Book()); 


What is the result? 

A. [A Guide to Java Tour:3, Beginning with Java:2] 

B. [Beginning with Java:2, A Guide to Java Tour:3] 

C. A compilation error occurs because the Book class does not override the abstract method compareTo(). 

D. An Exception is thrown at run time. 


Q22. Given the code fragment: 

public void recDelete (String dirName) throws IOException { 

File [ ] listOfFiles = new File (dirName) .listFiles(); 

if (listOfFiles ! = null && listOfFiles.length >0) { 

for (File aFile : listOfFiles) { 

if (aFile.isDirectory ()) { 

recDelete (aFile.getAbsolutePath ()); 

} else { if (aFile.getName ().endsWith (“.class”)) 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? 

A. The method deletes all the .class files in the Projects directory and its subdirectories. 

B. The method deletes the .class files of the Projects directory only. 

C. The method executes and does not make any changes to the Projects directory. 

D. The method throws an IOException. 


Q23. Given: 

public enum USCurrency { 

PENNY (1), 


DIME (10), 


private int value; 

public USCurrency(int value) { 

this.value = value; 

public int getValue() {return value;} 

public class Coin { 

public static void main (String[] args) { 

USCurrency usCoin =new USCurrency.DIME; 


Which two modifications enable the given code to compile? 

A. Nest the USCurrency enumeration declaration within the Coin class. 

B. Make the USCurrency enumeration constructor private. 

C. Remove the new keyword from the instantion of usCoin. 

D. Make the getter method of value as a static method. 

E. Add the final keyword in the declaration of value. 

Answer: A,E 

Q24. Given: 

class Book { 

int id; 

String name; 

public Book (int id, String name) { = id; = name; 

public boolean equals (Object obj) { //line n1 

boolean output = false; 

Book b = (Book) obj; 

if ( name))} 

output = true; 

return output; 

and the code fragment: 

Book b1 = new Book (101, “Java Programing”); 

Book b2 = new Book (102, “Java Programing”); 

System.out.println (b1.equals(b2)); //line n2 

Which statement is true? 

A. The program prints true. 

B. The program prints false. 

C. A compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) { 

D. A compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2)); 


Q25. Given the code fragment: 

ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 3, 0, 0, 0, ZoneID.of(“UTC-7”)); ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of(“UTC-5”)); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1 System.out.println(“Travel time is” + hrs + “hours”); 

What is the result? 

A. Travel time is 4 hours 

B. Travel time is 6 hours 

C. Travel time is 8 hours 

D. An exception is thrown at line n1. 


Update 1Z0-809 free question:

Q26. 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) { = data; 

this stIndex = start; 

this. lstIndex = end; 

protected void compute ( ) { 

int sum = 0; 

if (lstIndex – stIndex <= THRESHOLD_SIZE) { 

for (int i = stIndex; i < lstIndex; i++) { 

sum += data [i]; 


} 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? 

A. The program prints several values that total 55. 

B. The program prints 55. 

C. A compilation error occurs at line n1. 

D. The program prints several values whose sum exceeds 55. 


Q27. Given: 

public class Emp { 

String fName; 

String lName; 

public Emp (String fn, String ln) { 

fName = fn; 

lName = ln; 

public String getfName() { return fName; } 

public String getlName() { return lName; } 

and the code fragment: 

List<Emp> emp = Arrays.asList ( 

new Emp (“John”, “Smith”), 

new Emp (“Peter”, “Sam”), 

new Emp (“Thomas”, “Wale”)); 

//line n1 


Which code fragment, when inserted at line n1, sorts the employees list in descending order of fName and then ascending order of lName? 

A. .sorted (Comparator.comparing(Emp::getfName).reserved().thenComparing(Emp::getlName)) 

B. .sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName)) 

C. .map(Emp::getfName).sorted(Comparator.reserveOrder()) 




Q28. Which two are Java Exception classes? 

A. SercurityException 

B. DuplicatePathException 

C. IllegalArgumentException 

D. TooManyArgumentsException 

Answer: A,C 

Q29. Given the class definitions: 

And the code fragment of the main() method, 

What is the result? 

A. Java Java Java 

B. Java Jeve va 

C. Java Jeve ve 

D. Compilation fails 


Q30. Given: 

class ImageScanner implements AutoCloseable { 

public void close () throws Exception { 

System.out.print (“Scanner closed.”); 

public void scanImage () throws Exception { 

System.out.print (“Scan.”); 

throw new Exception(“Unable to scan.”); 

class ImagePrinter implements AutoCloseable { 

public void close () throws Exception { 

System.out.print (“Printer closed.”); 

public void printImage () {System.out.print(“Print.”); } 

and this code fragment: 

try (ImageScanner ir = new ImageScanner(); 

ImagePrinter iw = new ImagePrinter()) { 



} catch (Exception e) { 


What is the result? 

A. Scan.Printer closed. Scanner closed. Unable to scan. 

B. Scan.Scanner closed. Unable to scan. 

C. Scan. Unable to scan. 

D. Scan. Unable to scan. Printer closed.