Please enable JavaScript to use CodeHS

Want to receive Question of the Day updates? Subscribe Here

AP CSA Question of the Day Feb. 25, 2025

Reference
  1. Incorrect Correct No Answer was selected Invalid Answer

    The Person, Student and Teacher classes have the following instance variables, methods, and inheritance relationship:

    public class Person {
        private String name;
        private int age;
    
        public Person(String name, int age) { ... } // implementation omitted
        public String getName() { ... } // implementation omitted
        public int getAge() { ... } // implementation omitted
    }
    
    public class Student extends Person {
        private int grade;
        private double gpa;
    
        public Student(String name, int age) { ... } // implementation omitted
        public void setGrade(int grade) { ... } // implementation omitted
        public void setGPA(double gpa) { ... } // implementation omitted
        public int getGrade() { ... } // implementation omitted
        public double getGPA() { ... } // implementation omitted
    }
    
    public class Teacher extends Person {
        private String[] classesTaught;
    
        public Teacher(String name, int age) { ... } // implementation omitted
        public void addClass(String className) { ... } // implementation omitted
        public String[] getClassesTaught() { ... } // implementation omitted
    }
    Java

    Assume we have a Person object person, a Student object student, and a Teacher object teacher

    Which of the following is a valid instruction?