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

Задача . 37362


Задача

Темы:
public class Date
{
private int day;
private int month;
private int year;
public Date() //default constructor
{
...
}
public Date(int mo, int da, int yr) //constructor
{
...
}
public int month() //returns month of Date
{
...
}
public int day() //returns day of Date
{
...
}
public int year() //returns year of Date
{
...
}
//Returns String representation of Date as "m/d/y", e.g. 4/18/1985.
public string toString()
{
...
}
}

Here is a client program that uses Date objects:
public class BirthdayStuff
{
public static Date findBirthdate()
{
/* code to get birthDate */
return birthDate;
}
public static void Main(String[] args)
{
Date d = findBirthdate();
...
}
}

Which of the following is a correct replacement for
/* code to get birthDate */?

I) Console.WriteLine("Enter birthdate: mo, day, yr: ");
int m = Convert.ToInt32(Console.ReadLine()); //read user input
int d = Convert.ToInt32(Console.ReadLine()); //read user input
int y = Convert.ToInt32(Console.ReadLine()); //read user input
 Date birthDate = new Date(m, d, y);

II) Console.WriteLine("Enter birthdate: mo, day, yr: ");
int birthDate.month() = Convert.ToInt32(Console.ReadLine()); //read user input
int birthDate.day() = Convert.ToInt32(Console.ReadLine()); //read user input
int birthDate.year() = Convert.ToInt32(Console.ReadLine()); //read user input
Date birthDate = new Date(birthDate.month(), birthDate.day(),
birthDate.year());
III) Console.WriteLine("Enter birthdate: mo, day, yr: ");
int birthDate.month =Convert.ToInt32(Console.ReadLine()); //read user input
int birthDate.day = Convert.ToInt32(Console.ReadLine()); //read user input
int birthDate.year = Convert.ToInt32(Console.ReadLine()); //read user input
Date birthDate = new Date(birthDate.month, birthDate.day,birthDate.year);

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

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

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