Computer Science › Information Hiding
Class Person {
int height;
float weight;
``
public:
int getHeight();
void setHeight(int);
float getWeight();
void setWeight(float);
};
What is the access level of height
and weight
?
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;
}
}
Which of the following represents a method that returns the minute value of the clock?
Consider the following code :
public 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;
}
}
Which of the following defines a toString method that will output the time in 24-hour format in the following form:
1:51:03
(Notice that you need to pad the minutes and seconds. You can call 12 midnight "0".)