Consider the following declaration. public class Team { private String myName; p
ID: 3643377 • Letter: C
Question
Consider the following declaration.public class Team
{
private String myName;
public String name()
{ return myName; }
}
Team[] league = new Team[10];
Assume that the elements of the array league have been initialized. Which of the following statements can be used in a client class to print the name of the third team in league to the screen?
A.) System.out.println(league.myName[2]);
B.) System.out.println(league.name()[2]);
C.) System.out.println(league[2].myName);
D.) System.out.println(league[2].name());
E.) System.out.println(league.name(2));
Explanation / Answer
D
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.