Solved

It Has Been Suggested the Accessor Method Below Be Added

Question 41

Multiple Choice

It has been suggested the accessor method below be added to the class to return the Date one day later than the given date. public Date getNextDate()
{
If (day == lastDayOfMonth() )
{
Month++;
If (month == 12) { month = 1; }
Day = 1;
}
Else { day++; }
Return this;
}
What is wrong with this design?


A) You cannot return this from a method.
B) It uses lastDayOfMonth, a private method of the class.
C) It has the side effect of changing the Date.
D) Since it returns a Date other than this one, the class is not consistent.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions