Skip to main content

1Z0-816 Real Exam Questions

Java SE 11 Programmer II

80 questions available · Page 1 of 8

Updated Exam DumpsVerified AnswersPass Guarantee

Get Complete Exam Dumps
Question 1 Single choice

Given:

Which statement on line 1 enables this code fragment to compile?

  1. A

    Function function = String::toUpperCase;

  2. B

    UnaryOperator function = s -> s.toUpperCase();

  3. C

    UnaryOperator<String> function = String::toUpperCase;

  4. D

    Function<String> function = m -> m.toUpperCase();

Show answer and explanation

Correct answer: C

Explanation
Question 2 Single choice

Given:

List<String> longlist = List.of("Hello","World","Beat");
List<String> shortlist = new ArrayList<>();

Which code fragment correctly forms a short list of words containing the letter "e"?

  1. A

    Option A

  2. B

    Option B

  3. C

    Option C

  4. D

    Option D

Show answer and explanation

Correct answer: C

Question 3 Multiple choice

Given:

Which two are correct? (Choose two.)

  1. A

    Option A

  2. B

    Option B

  3. C

    Option C

  4. D

    Option D

  5. E

    Option E

Show answer and explanation

Correct answers: C, D

Question 4 Single choice

Given:

Which is true?

  1. A

    System.out is the standard output stream. The stream is open only when System.out is called.

  2. B

    System.in cannot reassign the other stream.

  3. C

    System.out is an instance of java.io.OutputStream by default.

  4. D

    System.in is the standard input stream. The stream is already open.

Show answer and explanation

Correct answer: D

Explanation

References:
https://www.geeksforgeeks.org/java-lang-system-class-java/

Question 5 Single choice

Given:

var fruits = List.of("apple", "orange", "banana", "lemon");

You want to examine the first element that contains the character n.

Which statement will accomplish this?

  1. A

    String result = fruits.stream().filter(f -> f.contains("n")).findAny();

  2. B

    fruits.stream().filter(f -> f.contains("n")).forEachOrdered(System.out::print);

  3. C

    Optional<String> result = fruits.stream().filter(f -> f.contains("n")).findFirst ();

  4. D

    Optional<String> result = fruits.stream().anyMatch(f -> f.contains("n"));

Show answer and explanation

Correct answer: B

Explanation
Question 6 Multiple choice

Given:

Which two interfaces can be used in lambda expressions? (Choose two.)

  1. A

    MyInterface1

  2. B

    MyInterface3

  3. C

    MyInterface5

  4. D

    MyInterface2

  5. E

    MyInterface4

Show answer and explanation

Correct answers: C, D

Explanation

References:
https://dzone.com/articles/functional-interface-and-lambda-expression

Question 7 Single choice

Given:

Which statement on line 1 enables this code to compile?

  1. A

    Function<Integer, Integer> f = n -> n * 2;

  2. B

    Function<Integer> f = n -> n * 2;

  3. C

    Function<int> f = n -> n * 2;

  4. D

    Function<int, int> f = n -> n * 2;

  5. E

    Function f = n -> n * 2;

Show answer and explanation

Correct answer: A

Explanation
Question 8 Single choice

Given:

Which is true about line 1?

  1. A

    If the value is not present, a NoSuchElementException is thrown at run time.

  2. B

    It always executes the System.out::print statement.

  3. C

    If the value is not present, a NullPointerException is thrown at run time.

  4. D

    If the value is not present, nothing is done.

Show answer and explanation

Correct answer: D

Explanation
Question 9 Multiple choice

var numbers = List.of(0,1,2,3,4,5,6,7,8,9);

You want to calculate the average of numbers.

Which two codes will accomplish this? (Choose two.)

  1. A

    double avg = numbers.stream().parallel().averagingDouble(a -> a);

  2. B

    double avg = numbers.parallelStream().mapToInt (m -> m).average().getAsDouble();

  3. C

    double avg = numbers.stream().mapToInt (i -> i).average().parallel();

  4. D

    double avg = numbers.stream().average().getAsDouble();

  5. E

    double avg = numbers.stream().collect(Collectors.averagingDouble(n -> n));

Show answer and explanation

Correct answers: B, D

Explanation
Question 10 Single choice

Which is a proper JDBC URL?

  1. A

    jdbe.mysql.com://localhost:3306/database

  2. B

    http://localhost.mysql.com:3306/database

  3. C

    http://localhostmysql.jdbc:3306/database

  4. D

    jdbc:mysql://localhost:3306/database

Show answer and explanation

Correct answer: D

Explanation

References:
https://vladmihalcea.com/jdbc-driver-connection-url-strings/