exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 196 discussion

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

Given the code fragment:
List<String> empDetails = Arrays.asList("100, Robin, HR", "200, Mary, AdminServices","101, Peter, HR"); empDetails.stream()
.filter(s-> s.contains("r"))
.sorted()
.forEach(System.out::println); //line n1
What is the result?

  • A. 100, Robin, HR 101, Peter, HR
  • B. E. A compilation error occurs at line n1.
  • C. 101, Peter, HR 200, Mary, AdminServices
  • D. 100, Robin, HR 200, Mary, AdminServices 101, Peter, HR
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
pul26
Highly Voted 4 years, 1 month ago
Answer is C, tested
upvoted 10 times
maslac
3 years, 10 months ago
correct
upvoted 3 times
...
...
6c84cb9
Most Recent 4 months, 3 weeks ago
Sorting When sorting in alphabetical order, Java starts with the first character of each string: First character: 1 (for "100, Robin, HR") First character: 1 (for "101, Peter, HR") First character: 2 (for "200, Mary, AdminServices") Since "100, Robin, HR" and "101, Peter, HR" start with 1, Java compares them further: "100, Robin, HR" (less, because after 1 it has 0) "101, Peter, HR" (more, because after 1 it has 01) Finally, when sorting elements from the same group, the sort compares the characters one by one, which gives the order: "100, Robin, HR" "101, Peter, HR" "200, Mary, AdminServices" Final Order The final order after sorting is: Copy code 100, Robin, HR 101, Peter, HR 200, Mary, AdminServices
upvoted 1 times
...
asdfjhfgjuaDCV
11 months ago
Answer is c tested. import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<String> empDetails = Arrays.asList( "100, Robin, HR", "200, Mary, AdminServices", "101, Peter, HR" ); empDetails.stream() .filter(s -> s.contains("r")) .sorted() .forEach(System.out::println); } }
upvoted 1 times
...
steefaand
11 months, 4 weeks ago
Selected Answer: C
C is correct.
upvoted 1 times
...
WilsonKKerll
2 years, 10 months ago
Answer is C.
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