Oracle Java SE 8 Programmer II 1z0-809 Question # 47 Topic 5 Discussion

Oracle Java SE 8 Programmer II 1z0-809 Question # 47 Topic 5 Discussion

1z0-809 Exam Topic 5 Question 47 Discussion:
Question #: 47
Topic #: 5

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?


A.

10123 Ford10124 BMW


B.

10124 BMW10123 Ford


C.

A compilation error occurs.


D.

A ClassCastException is thrown at run time.


Get Premium 1z0-809 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.