1Z0-809 Dumps

1Z0-809 Free Practice Test

Oracle 1Z0-809: Java SE 8 Programmer II

QUESTION 36

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 = null;
Optional
addrs1 = Optional.ofNullable (address);
Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : “City Not available”;
What is the result?

Correct Answer: B

QUESTION 37

Given the code fragment:
List str = Arrays.asList (“my”, “pen”, “is”, “your’, “pen”); Predicate test = s -> {
int i = 0;
boolean result = s.contains (“pen”);
System.out.print(i++) + “:”); return result;
};
str.stream()
.filter(test)
.findFirst()
.i fPresent(System.out ::print); What is the result?

Correct Answer: A

QUESTION 38

Given:
<>

Correct Answer: D

QUESTION 39

Given:
< ><>>< ><>

Correct Answer: D

QUESTION 40

Given the structure of the STUDENT table: Student (id INTEGER, name VARCHAR) Given:
public class Test {
static Connection newConnection =null;
public static Connection get DBConnection () throws SQLException { try (Connection con = DriveManager.getConnection(URL, username, password)) {
newConnection = con;
}
return newConnection;
}
public static void main (String [] args) throws SQLException { get DBConnection ();
Statement st = newConnection.createStatement(); st.executeUpdate(“INSERT INTO student VALUES (102, ‘Kelvin’)”);
}
}
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the URL, userName, and passWord exists. The SQL query is valid.
What is the result?

Correct Answer: C