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() {

     int hours = seconds / 3600;

     return (seconds - hours * 3600);

}

public int getMinutes() {

     return seconds / 60;

}

public int getMinutes() {

    return mins;

}

public int getMinutes() {

     return seconds * 60;

}

public int getMinutes() {

     int hours = seconds / 3600;

     return (seconds - hours * 3600) / 60;

}

1/12 questions

0%

Access results and powerful study features!

Take 15 seconds to create an account.
Start now! Create your free account and get access to features like:
  • Full length diagnostic tests
  • Invite your friends
  • Access hundreds of practice tests
  • Monitor your progress over time
  • Manage your tests and results
  • Monitor the progress of your class & students
By clicking Create Account you agree that you are at least 13 years old and you agree to the Varsity Tutors LLC Terms of Use and Privacy Policy.
Learning Tools by Varsity Tutors