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()))
D and E
C and D
No, you are wrong.
.map(v -> v.getVId()).sorted() returns a stream of sorted IDs.
So D, E is the right answer.