Self-Assessment Exercises
Chapter 18:
Sorting
1.
In Java, an item is sortable if it supports the ________ interface.
a.
Comparable
b.
Comparison
c.
LessThan
d.
Sortable
2.
When Java is unable to cast an object it ________.
a.
assigns
null
b.
leaves the type unchanged
c.
throws a
ClassCastException
d.
throws an
IllegalCastException
3.
Which of the following sorting algorithms is almost never used because of its poor performance?
a.
bubble sort
b.
quicksort
c.
selection sort
d.
shell sort
4.
Which of the following is the best overall sort algorithm?
a.
insertion sort
b.
quicksort
c.
selection sort
d.
shell sort
5.
Which of the following sort algorithms is recursive in nature, and is typically implemented in a recursive fashion?
a.
bubble sort
b.
insertion sort
c.
quicksort
d.
shell sort