Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 1z0-819 topic 1 question 135 discussion

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

Given:



Which statement will refactor line 2 to use a lambda expression?

  • A. fruits.sort((String d, String e) -> (e.compareTo(d);));
  • B. fruits.sort( o, p -> p.compareTo(o));
  • C. fruits.sort((String x, y) -> (return y.compareTo(x)));
  • D. fruits.sort((a, b) -> (return b.compareTo(a);));
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
ASPushkin
2 weeks, 2 days ago
there is no right answer new Comparator() -> new Comparator<String>() even if List fruit is a raw type list List.of("banana", "orange", "apple", "lemon"); is an Unmodifiable List so there is java.lang.UnsupportedOperationException on fruits.sort()
upvoted 1 times
...
d7bb0b2
4 months ago
Selected Answer: A
no answer correct list.of is inmutable. if that is corrected then: A and D are correct (correction sintax for ;)
upvoted 1 times
...
Samps
4 months ago
A is the most correct but it gives a compilation error as a result of ';'
upvoted 1 times
...
duydn
5 months, 2 weeks ago
Selected Answer: A
If 1st line is List<String> -> A will be correct answer.
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 ...