Solved

Consider the Following Class: Public Class Player Implements Comparable

Question 12

Multiple Choice

Consider the following class: public class Player implements Comparable
{
Private String name;
Private int goalsScored;
// other methods go here
Public int compareTo(Object otherObject)
{
__________________________________
Return (goalsScored - otherPlayer.goalsScored) ;
}
}
What statement can be used to complete the compareTo() method?


A) Player otherPlayer = otherObject;
B) Object otherPlayer = otherObject;
C) Player otherPlayer = (Player) otherObject;
D) Object otherPlayer = (Player) otherObject;

Correct Answer:

verifed

Verified

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

Related Questions