Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
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 */ }
Which of the following could be used for the missing code to allow the program to compile?
1.
public Grandparent() { super("Karel", "Tracy"); }
2.
public Grandparent(String first, String middle, String last) { super(last, first); middleName = middle; }
3.
public Grandparent(String first, String middle) { super(first); middleName = middle; }
1 Only
2 Only
1 and 2 Only
2 and 3 Only
1, 2, and 3