exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 116 discussion

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

Given:
and the code fragment:

Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?

  • A. .sorted ((v1, v2) -> v1.getVId() < v2.getVId())
  • B. .sorted (Comparable.comparing (Vehicle: :getVName)).reversed ()
  • C. .map (v -> v.getVid()) .sorted ()
  • D. .sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVid()))
  • E. .sorted(Comparator.comparing ((Vehicle v) -> v.getVId()))
Show Suggested Answer Hide Answer
Suggested Answer: DE 🗳️

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
laura_lu93
Highly Voted 3 years, 4 months ago
correct are D and E. tested! because C print their ID not their Name
upvoted 6 times
mevlt
2 years, 4 months ago
Actually C is Runtime Exception because Vehicle class doesn't implement Comparable interface.
upvoted 1 times
...
...
asdfjhfgjuaDCV
Most Recent 4 months ago
D and E are the correct answer
upvoted 1 times
...
steefaand
5 months, 2 weeks ago
Selected Answer: DE
D and E are correct.
upvoted 1 times
...
lnrdgst
2 years, 2 months ago
I believe that the letter D is also incorrect because there is no method v2.getVid() but v2.getVId(). If alternative D had the call to method v2.getVId it would be right. No other alternative compiled, unfortunately only letter E is true by my tests.
upvoted 1 times
...
Eason_from_the_future
2 years, 10 months ago
B should be ".sorted(Comparator.comparing(Vehicle::getvName).reversed())"
upvoted 2 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