New Year Special 60% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: bestdeal

Free Oracle 1z0-809 Practice Exam with Questions & Answers | Set: 5

Questions 41

Given the code fragment:

public class Foo {

public static void main (String [ ] args) {

Map unsortMap = new HashMap< > ( );

unsortMap.put (10, “z”);

unsortMap.put (5, “b”);

unsortMap.put (1, “d”);

unsortMap.put (7, “e”);

unsortMap.put (50, “j”);

Map treeMap = new TreeMap (new

Comparator ( ) {

@Override public int compare (Integer o1, Integer o2) {return o2.compareTo

(o2); } } );

treeMap.putAll (unsortMap);

for (Map.Entry entry : treeMap.entrySet () ) {

System.out.print (entry.getValue () + “ “);

}

}

}

What is the result?

Options:
A.

A compilation error occurs.

B.

d b e z j

C.

j z e b d

D.

z b d e j

Oracle 1z0-809 Premium Access
Questions 42

Given the code fragment:

1z0-809 Question 42

Which code fragment, when inserted at line n1, enables the code to print /First.txt?

Options:
A.

Path iP = new Paths (“/First.txt”);

B.

Path iP = Paths.toPath (“/First.txt”);

C.

Path iP = new Path (“/First.txt”);

D.

Path iP = Paths.get (“/”, “First.txt”);

Questions 43

Given:

class Vehicle {

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + “:” + name;

}

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, “Ford”));

vehicles.add(new Vehicle (10124, “BMW”));

System.out.println(vehicles);

What is the result?

Options:
A.

10123 Ford10124 BMW

B.

10124 BMW10123 Ford

C.

A compilation error occurs.

D.

A ClassCastException is thrown at run time.

Questions 44

Given the definition of the Employee class:

1z0-809 Question 44

and this code fragment:

1z0-809 Question 44

What is the result?

Options:
A.

[sales:Ada, hr:Bob, sales:Bob, hr:Eva]

B.

[Ada:sales, Bob:sales, Bob:hr, Eva:hr]

C.

[hr:Eva, hr:Bob, sales:Bob, sales:Ada]

D.

[hr:Bob, hr:Eva, sales:Ada, sales:Bob]

Questions 45

Which statement is true about the DriverManager class?

Options:
A.

It returns an instance of Connection.

B.

It executes SQL statements against the database.

C.

It only queries metadata of the database.

D.

it is written by different vendors for their specific database.

Questions 46

Given:

1z0-809 Question 46

Your design requires that:

  • fuelLevel of Engine must be greater than zero when the start() method is invoked.
  • The code must terminate if fuelLevel of Engine is less than or equal to zero.

Which code fragment should be added at line n1 to express this invariant condition?

Options:
A.

assert (fuelLevel) : “Terminating…”;

B.

assert (fuelLevel > 0) : System.out.println (“Impossible fuel”);

C.

assert fuelLevel < 0: System.exit(0);

D.

assert fuelLevel > 0: “Impossible fuel” ;

Questions 47

Given:

1z0-809 Question 47

What is the result?

Options:
A.

–catch--finally--dostuff-

B.

–catch-

C.

–finally--catch-

D.

–finally-dostuff--catch-

Questions 48

Given the code fragment:

UnaryOperator uo1 = s -> s*2;//line n1

List loanValues = Arrays.asList(1000.0, 2000.0);

loanValues.stream()

.filter(lv -> lv >= 1500)

.map(lv -> uo1.apply(lv))//line n2

.forEach(s -> System.out.print(s + “ “));

What is the result?

Options:
A.

4000.0

B.

4000

C.

A compilation error occurs at line n1.

D.

A compilation error occurs at line n2.

Questions 49

Given the code fragment:

Path path1 = Paths.get(“/app/./sys/”);

Path res1 = path1.resolve(“log”);

Path path2 = Paths.get(“/server/exe/”);

Path res1 = path2.resolve(“/readme/”);

System.out.println(res1);

System.out.println(res2);

What is the result?

Options:
A.

/app/sys/log/readme/server/exe

B.

/app/log/sys/server/exe/readme

C.

/app/./sys/log/readme

D.

/app/./sys/log/server/exe/readme

Questions 50

Given:

public class Product {

int id; int price;

public Product (int id, int price) {

this.id = id;

this.price = price;

}

Public String toString () { return id + “:” + price;)

}

and the code fragment:

List products = new ArrayList <> (Arrays.asList(new Product(1, 10),

new Product (2, 30),

new Product (3, 20));

Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {

p1.price+=p2.price;

return new Product (p1.id, p1.price);});

products.add(p);

products.stream().parallel()

.reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)

.ifPresent(System.out: :println);

What is the result?

Options:
A.

4:60

B.

2:30

C.

4:602:303:201:10

D.

4:0

E.

The program prints nothing

Exam Code: 1z0-809
Certification Provider: Oracle
Exam Name: Java SE 8 Programmer II
Last Update: Mar 28, 2025
Questions: 196