Subclass Constructor Initialization
Which of the following could replace /* missing code */ in the SchoolClub constructor to ensure that all instance variables are initialized correctly?
Refer to the following classes
public class Club
{
private ArrayList<String> members;
public Club() { }
public Club(ArrayList<String> theMembers) {
{ members = theMembers; }
}
/* Additional implementation not shown */
}
public class SchoolClub extends Club
{
private String advisor;
public SchoolClub(String theAdvisor, ArrayList<String> theMembers)
{
/* missing code */
}
/* Additional implementation not shown */
}
Which of the following could replace /* missing code */ in the SchoolClub constructor to ensure that all instance variables are initialized correctly?
A
advisor = theAdvisor;
B
super(new Club(theMembers)); advisor = theAdvisor;
C
super(theMembers);
D
super(theMembers); advisor = theAdvisor;
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | psak12 | 0 | 1 | 1m 17s | -87 |
| #3 | suhanakochhar006 | 1 | 1 | 5m 47s | -247 |
APFIVE