Oracle
1Z0-809 · Question #213
1Z0-809 Question #213: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #213. The question stem and answer options stay visible for context.
Question
Given:
public class Vehicle {
int vid;
String vName;
public Vehicle(int vIdArg, String vNameArg) {
this.vid = vIdArg;
this.vName = vNameArg;
}
public int getVId() { return vid; }
public String getVName() { return vName; }
public String toString() { return vName; }
}
and the code fragment:
List<Vehicle> vehicle = Arrays.asList(
new Vehicle(2, "Car"),
new Vehicle(3, "Bike"),
new Vehicle(1, "Truck"));
vehicle.stream()
// line n1
.forEach(System.out::print);
Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?Options
- A.sorted((v1, v2) -> v1.getVId() - v2.getVId())
- B.sorted(Comparable.comparing(Vehicle::getVName()).reversed())
- C.map(v -> v.getVId())
- D.sorted((v1, v2) -> Integer.compare(v1.getVId(), v2.getVId()))
- E.sorted(Comparator.comparing((Vehicle v) -> v.getVId()))
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.