Олимпиадный тренинг

Задача . 37341


Задача

Темы:
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; }
}

The following code segment is to print out a list of addresses:
  for (Address addr : list)
 {
   /* more code */
 }
Which is a correct replacement for /* more code */?

I
System.out.println(list[i].getName());
System.out.println(list[i].getStreet());
System.out.print(list[i].getCity() + ", ");
System.out.print(list[i].getState() + " ");
System.out.println(list[i].getZip());

II
System.out.println(addr.getName());
System.out.println(addr.getStreet());
System.out.print(addr.getCity() + ", ");
System.out.print(addr.getState() + " ");
System.out.println(addr.getZip());

III
System.out.println(addr);

(A) I only
(B) II only
(C) III only
(D) I and II only
(E) I, II, and III

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя