Oracle certification · Exam 1z0-809

1z0-809 Mock Exam Page 4

Java SE 8 Programmer II

Free 1z0-809 mock exam questions 31–38, each with the answer and an explanation.

20 questions · 33 minutes · free, no sign-up

Free 1z0-809 questions

31–38 of 38 free
Question 31 Choose 1

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?

Show answerHide answer

Correct answer: D

A NullPointerException is thrown as runtime.

Question 32 Choose 1

public class StringReplace {
public static void main(String[] args) {
String message = "Hi everyone!";
System.out.println("message = " + message.replace("e", "X")); }
}
What is the result?

Show answerHide answer

Correct answer: B

message = Hi XvXryonX!

Question 33 Choose 1

Given the code fragment:
Path p1 = Paths.get(“/Pics/MyPic.jpeg”);
System.out.println (p1.getNameCount() +
“:” + p1.getName(1) +
“:” + p1.getFileName());
Assume that the Pics directory does NOT exist.
What is the result?

Show answerHide answer

Correct answer: C

1:Pics:/Pics/ MyPic.jpeg

Question 34 Choose 1

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 answerHide answer

Correct answer: A

{EUROPE = [Italy, Germany], ASIA = [Japan]}

Question 35 Choose 1

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

Show answerHide answer

Correct answer: E

A compilation error occurs.

Question 36 Choose 1

The protected modifier on a Field declaration within a public class means that the field
______________.

Show answerHide answer

Correct answer: D

Can be read and written from this class and its subclasses defined in any package

Explanation

http://beginnersbook.com/2013/05/java-access-modifiers/

Question 37 Choose 1

A method is declared to take three arguments. A program calls this method and passes
only two arguments. What is the results?

Show answerHide answer

Correct answer: A

Compilation fails.

Question 38 Choose 1

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

Show answerHide answer

Correct answer: C

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

Explanation

Reference: http://winterbe.com/posts/2014/03/16/java-8-tutorial/ (functions)

That's the last free question

You've seen the free 30% (38 of 128 questions). Full access unlocks every question and full-length 1z0-809 mock exams (65 questions, 105 minutes), a different mock on every attempt.

Unlock full mock exam
Full mock exam

Sit the 1z0-809 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real 1z0-809 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full 1z0-809 mock exam
  • 65questions per mock
  • 105 mintime limit
  • 128questions in the bank
  • Newmock on every attempt