Test: Computer Science

Consider the code below:

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 issues could be raised regarding the code?

There is insufficient data verification for the mutator methods.

There is an error in the setMinutes calculation.

There are no issues.

The setMinutes method should return an integer value.

There is a potential null pointer exception in one of the methods.

1/2 questions


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