Solved

Suppose You Are Implementing the Comparable Interface in a Class

Question 27

Short Answer

Suppose you are implementing the comparable interface in a class representing a Person, where the ordering is based on the age of the person. Write a compareTo method for this class. You may assume that there is an instance variable called age and a method called getAge.

Correct Answer:

verifed

Verified

public int compareTo...

View Answer

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions