Refer to the following classes for Question.
public class Address
{
private String name;
private String street;
private String city;
private String state;
private String zip;
//constructors
...
//accessors
public String getName()
{ return name; }
public String getStreet()
{ return street; }
public String getCity()
{ return city; }
public String getState()
{ return state; }
public String getZip()
{ return zip; }
}
public class Student
{
private int idNum;
private double gpa;
private Address address;
//constructors
...
//accessors
public Address getAddress()
{ return address; }
public int getIdNum()
{ return idNum; }
public double getGpa()
{ return gpa; }
}
A client method has this declaration:
Student[] allStudents = new Student[NUM_STUDS]; //NUM_STUDS is
//an int constant
Here is a code segment to generate a list of Student names only. (You may assume that allStudents has been initialized.)
foreach (Student student in allStudents)
/* code to print list of names */
Which is a correct replacement for
/* code to print list of names */?
(A) Console.WriteLine(allStudents.getName());
(B) Console.WriteLine(student.getName());
(C) Console.WriteLine(student.getAddress().getName());
(D) Console.WriteLine(allStudents.getAddress().getName());
(E) Console.WriteLine(student[i].getAddress().getName());