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

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()))

Download Printable PDF. VALID exam to help you PASS.

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

    1. No, you are wrong.
      .map(v -> v.getVId()).sorted() returns a stream of sorted IDs.

      So D, E is the right answer.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.