and this code fragment:

What is the result?

A.

10123:Ford
10124:BMW

B.

10124:BMW
10123:Ford

C. A compilation error occurs.
D. A ClassCastException is thrown at run time.

題解

題目提供的程式會在第21行拋出ClassCastException,因為TreeSet的元素必須要實作Comparable介面,才可以進行自動排序。