exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 160 discussion

Actual exam question from Oracle's 1z0-819
Question #: 160
Topic #: 1
[All 1z0-819 Questions]

Given:



Which statement on line 1 enables this code to compile?

  • A. Supplier function = () -> states.contains(“N”);
  • B. Function function = s -> s.contains(‘N”);
  • C. Consumer function = s -> {if(s.contains(“N”)) states.remove(s);};
  • D. Predicate function = s -> s.contains(“N”);
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
ASPushkin
2 months, 3 weeks ago
D: Predicate function = s -> s.contains("N"); not correct syntax raw type Predicate class is considering parameter "s" as a type of Object so there is an exception MyClass.java:4: error: cannot find symbol Predicate function = s -> s.contains("N"); should be Predicate<String> function = s -> s.contains("N");
upvoted 1 times
...
d7bb0b2
1 year ago
Selected Answer: D
D:=> removeif accept a predicated only
upvoted 1 times
...
Omnisumem
1 year, 3 months ago
Selected Answer: D
Tested: D. Actually: Predicate<String> function = s -> s.contains("N");
upvoted 1 times
...
Stavok
1 year, 5 months ago
Selected Answer: D
D is Correct A List of String objects representing states is created and assigned to the states variable. A Predicate<String> functional interface is created using a lambda expression and assigned to the function variable. The lambda expression checks if a given String contains the character "N".The removeIf() method is called on the states list, passing in the function variable as an argument. This method removes all elements from the list that satisfy the given predicate. So, at the end of the program, all elements in the states list that contain the character "N" will be removed.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago