11.6 Exercises
Exercises
Which of the following are examples of subtype polymorphism?
How would you compare two strings alphabetically in Java?
Suppose we correctly define a
Comparator
class calledSixComparator
for integers that compares them based on the number of6
s they contain. What will the code(new SixComparator()).compare(12345678, 45666678)
return?What is the main difference between the
Comparable
andComparator
interfaces?
Solutions
Last updated