Create an account to track your scores
and create your own practice tests:
Test: AP Computer Science A
Consider the following code:
public static class Clock {
private int seconds;
public Clock(int s) {
seconds = s;
}
public void setTime(int s) {
seconds = s;
}
public void setSeconds(int s) {
int hoursMinutes = seconds - seconds % 60;
seconds = hoursMinutes + s;
}
public void setMinutes(int min) {
int hours = seconds / 3600;
int currentSeconds = seconds % 60;
seconds = hours + min * 60 + currentSeconds;
}
}
1. | Which of the following represents a method that returns the minute value of the clock? |
public int getMinutes() {
return mins;
}
public int getMinutes() {
int hours = seconds / 3600;
return (seconds - hours * 3600);
}
public int getMinutes() {
return seconds / 60;
}
public int getMinutes() {
return seconds * 60;
}
public int getMinutes() {
int hours = seconds / 3600;
return (seconds - hours * 3600) / 60;
}
Certified Tutor
Certified Tutor
