Pass the Oracle Java SE 1z0-809 Questions and answers with CertsForce

Viewing page 4 out of 7 pages
Viewing questions 31-40 out of questions
Questions # 31:

Given:

Question # 31

and the code fragment:

Question # 31

What is the result?

Options:

A.

0.0


B.

1500.0


C.

A compilation error occurs.


D.

2000.0


Expert Solution
Questions # 32:

Given:

Question # 32

What is the result?

Options:

A.

–catch--finally--dostuff-


B.

–catch-


C.

–finally--catch-


D.

–finally-dostuff--catch-


Expert Solution
Questions # 33:

Given the code fragment:

List colors = Arrays.asList(“red”, “green”, “yellow”);

Predicate test = n - > {

System.out.println(“Searching…”);

return n.contains(“red”);

};

colors.stream()

.filter(c -> c.length() >= 3)

.allMatch(test);

What is the result?

Options:

A.

Searching…


B.

Searching…Searching…


C.

Searching…Searching…Searching…


D.

A compilation error occurs.


Expert Solution
Questions # 34:

Given the code fragment:

Question # 34

What is the result?

Options:

A.

Word: why what when


B.

Word: why Word: why what Word: why what when


C.

Word: why Word: what Word: when


D.

Compilation fails at line n1.


Expert Solution
Questions # 35:

Which statement is true about the single abstract method of the java.util.function.Function interface?

Options:

A.

It accepts one argument and returns void.


B.

It accepts one argument and returns boolean.


C.

It accepts one argument and always produces a result of the same type as the argument.


D.

It accepts an argument and produces a result of any data type.


Expert Solution
Questions # 36:

Given the code fragments:

Question # 36

and

Question # 36

What is the result?

Options:

A.

null


B.

A compilation error occurs.


C.

DogCatMouse


D.

[Dog, Cat, Mouse]


Expert Solution
Questions # 37:

Given:

Question # 37

and the code fragment:

Question # 37

Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?

Options:

A.

.sorted ((v1, v2) -> v1.getVId() < v2.getVId())


B.

.sorted (Comparable.comparing (Vehicle: :getVName)).reversed ()


C.

.map (v -> v.getVid()).sorted ()


D.

.sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid()))


E.

.sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))


Expert Solution
Questions # 38:

Given:

Item table

• ID, INTEGER: PK

• DESCRIP, VARCHAR(100)

• PRICE, REAL

• QUANTITY< INTEGER

And given the code fragment:

9. try {

10.Connection conn = DriveManager.getConnection(dbURL, username, password);

11. String query = “Select * FROM Item WHERE ID = 110”;

12. Statement stmt = conn.createStatement();

13. ResultSet rs = stmt.executeQuery(query);

14.while(rs.next()) {

15.System.out.println(“ID:“ + rs.getString(1));

16.System.out.println(“Description:“ + rs.getString(2));

17.System.out.println(“Price:“ + rs.getString(3));

18. System.out.println(Quantity:“ + rs.getString(4));

19.}

20. } catch (SQLException se) {

21. System.out.println(“Error”);

22. }

Assume that:

The required database driver is configured in the classpath.

The appropriate database is accessible with the dbURL, userName, and passWord exists.

The SQL query is valid.

What is the result?

Options:

A.

An exception is thrown at runtime.


B.

Compilation fails.


C.

The code prints Error.


D.

The code prints information about Item 110.


Expert Solution
Questions # 39:

Given the code fragments:

class Employee {

Optional

address;

Employee (Optional

address) {

this.address = address;

}

public Optional

getAddress() { return address; }

}

class Address {

String city = “New York”;

public String getCity { return city: }

public String toString() {

return city;

}

}

and

Address address = new Address;

Optional

addrs1 = Optional.ofNullable (address);

Employee e1 = new Employee (addrs1);

String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : “City Not

available”;

System.out.println(eAddress);

What is the result?

Options:

A.

New York


B.

City Not available


C.

null


D.

A NoSuchElementException is thrown at run time.


Expert Solution
Questions # 40:

Which two code blocks correctly initialize a Locale variable? (Choose two.)

Options:

A.

Locale loc1 = “UK”;


B.

Locale loc2 = Locale.getInstance(“ru”);


C.

Locale loc3 = Locale.getLocaleFactory(“RU”);


D.

Locale loc4 = Locale.UK;


E.

Locale loc5 = new Locale (“ru”, “RU”);


Expert Solution
Viewing page 4 out of 7 pages
Viewing questions 31-40 out of questions