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

Задача . 8


Задача

Темы:
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()
{
...
}
}


Consider the implementation of a write() method that is added to the Date class:
/** Write the date in the form m/d/y, for example 2/17/1948. */
public void write()
{
/* implementation code */
}
Which of the following could be used as /* implementation code */?

I System.out.println(month + "/" + day + "/" + year);
II System.out.println(month() + "/" + day() + "/" + year());
III System.out.println(this);

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

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

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