2. Refer to the following three class declarations. public class…
Question Answered step-by-step 2. Refer to the following three class declarations. public class… 2. Refer to the following three class declarations. public class Person{ private int age; public Person(int a) { age = a; } public getAge() { return age; }} public class Student extends Person{ private double gpa; public Student(int a, double g) { super(a); gpa = g; } public getGPA() { return gpa; } public String toString() { return(getAge + ” ” + gpa); }} public class Course{ private Student[] students; public Course(int size, int a, double g) { /* Missing code 1 */ } public void displayCourse() { /* Missing code 2 */ }}Consider the following code segment and the previously mentioned three classes. int count = 6; // number of students in the courseint age = 15; // initial age for each studentdouble gpa = 3.875; // initial gpa for each studentCourse algebra = new Course(content, age, gpa);algebra.displayCourse();Which of the following implementations of /* missing code 1 */ will construct the Course object correctly? Implementation Istudents = new Student[size];for (Students student: students) student = new Student(a, g); Implementation IIstudents = new Student[size];for (int k = 0; k < students.length; k++) students[k] = new Student(a, g); Implementation IIIstudents = new Person[size];for (int k = 0; k < students.length; k++) students[k] = new Person(a, g); I and IIII onlyIII onlyII and IIII only Computer Science Engineering & Technology Java Programming MATH ab Share QuestionEmailCopy link Comments (0)


