AP® Computer Science A

Array of Athlete Objects: Determining Best Rank

APCSA-IKGYTP

The Athlete class is used to keep track of an athlete’s name, sport, ranking, and age. Assume that there are accessor methods named getName(), getSport(), getRank(), and getAge() in the Athlete class to retrieve this information from an Athlete object.

Which segment of code will print the name, age, ranking, and sport of the single athlete with the best ranking in the athletes array?

Note the best ranking is defined as the lowest ranking number (i.e. a ranking of 5 is better than a ranking of 10).

Athlete[] athletes = // Assume that his array is full of Athlete objects