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

Задача . 10


Задача

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


 A method in a client program for the Date class has this declaration:
Date d1 = new Date(mo, da, yr);
where mo, da, and yr are previously defined integer variables. The same method now creates a second Date object d2 that is an exact copy of the object d1 refers
to. Which of the following code segments will not do this correctly?

I Date d2 = d1;
II Date d2 = new Date(mo, da, yr);
III Date d2 = new Date(d1.month(), d1.day(), d1.year());

(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
Правила оформления программ и список ошибок при автоматической проверке задач

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