Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day April 8, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    Given the following class relationship

    public class Child
    {
        private String familyName;
    
        public Child(String name){
            familyName = name;
        }
    
    
    }
    
    public class Parent extends Child
    {
        private String firstName;
    
        public Parent(String firstName, String lastName)
        {
            super(lastName)
            this.firstName = firstName;
        }
    }
    
    public class Grandparent extends Parent
    {
        private String middleName;
    
        /* Missing Code */
    }
    Java

    Which of the following could be used for the missing code to allow the program to compile?

    1.

    public Grandparent()
    {
        super("Karel", "Tracy");
    }
    Java

    2.

    public Grandparent(String first, String middle, String last)
    {
        super(last, first);
        middleName = middle;
    }
    Java

    3.

    public Grandparent(String first, String middle)
    {
        super(first);
        middleName = middle;
    }
    Java