Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy

Calling Superclass Constructors

Mark
< Prev
Next >

Consider the following class hierarchy.

public class Student 
{
    private int gradYear;
    private double gpa;

    /* implementation not shown */
}

public class UnderClassman extends Student 
{
    private int homeRoomNum;
    private String counselor;

    /* implementation not shown */
}

public class Freshman extends UnderClassman 
{
    private int middleSchoolCode;
    /* implementation not shown */
}

Assume that the constructors for these classes have the following signatures.

public Student(int gradYear, double gpa)
public UnderClassman(int gradYear, double gpa, int homeRoomNum, String counselor)
public Freshman(int gradYear, double gpa, int homeRoomNum, String counselor, int middleSchoolCode)

Which of the following shows the correct call to the superclass constructor that would appear in the body of the Freshman constructor?

A

super(homeRoomNum, counselor);

B

super(gradYear, gpa, homeRoomNum, counselor, middleSchoolCode);

C

super(gradYear, gpa, homeRoomNum, counselor);

D

super();

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|