Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle Exam 1Z0-809 Topic 2 Question 8 Discussion

Actual exam question for Oracle's 1Z0-809 exam
Question #: 8
Topic #: 2
[All 1Z0-809 Questions]

Given:

class Vehicle {

int vno;

String name;

public Vehicle (int vno, String name) {

this.vno = vno,;

this.name = name;

}

public String toString () {

return vno + '':'' + name;

}

}

and this code fragment:

Set vehicles = new TreeSet <> ();

vehicles.add(new Vehicle (10123, ''Ford''));

vehicles.add(new Vehicle (10124, ''BMW''));

System.out.println(vehicles);

What is the result?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Blondell
14 days ago
Wait, the class doesn't implement Comparable? How are we supposed to sort the vehicles then? I'll go with C, a compilation error is bound to happen.
upvoted 0 times
Brandon
17 hours ago
User1
upvoted 0 times
...
...
Van
17 days ago
I'm not sure, but I think the TreeSet will use the natural ordering of the Vehicle objects based on the compareTo method.
upvoted 0 times
...
Antonio
18 days ago
I agree with Genevieve, the code fragment adds vehicles to a TreeSet which will sort them in natural order.
upvoted 0 times
...
Genevieve
20 days ago
I think the answer is A) 10123 Ford10124 BMW.
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77