| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice Test
Share
easy Solved by 2 students
Subclass Constructor Initialization
< Prev
Next >

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;

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2psak1201 1m 17s -87
#3suhanakochhar00611 5m 47s -247
APFIVE © 2020.
Email: [email protected]|Privacy Policy