Consider the partial Date class below which represents a day of the year. public class Date
{
Private int month; // A value between 1 and 12
Private int day; // A value between 1 and the last day
// of the month
Public int getMonth() { return month; }
Public void setMonth(int newMonth)
{
If (newMonth >= 1 && newMonth <= 12) { month = newMonth; }
}
Public int getDay() { return day; }
Private int lastDayOfMonth()
{
Switch (month)
{
Case 9: case 4: case 6: case 11:
Return 30;
Case 2: return 28;
Default: return 31;
}
}
}
What type of method is getMonth?
A) mutator
B) constructor
C) accessor
Correct Answer:
Verified
Q42: Where in a class should static variables
Q50: Which command would execute a program with
Q51: Which of the following statements is true
Q51: Why is a static variable also referred
Q52: Which of the following statements describes an
Q52: Which of the following constitutes a common
Q55: Which perspective should be used in formulating
Q56: A static method can have which of
Q59: Pre- and postconditions may be viewed as
Q60: In which of the following cases could
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents