Test: Computer Science

1.

What is wrong with this loop?

int i = 0;

int count = 20;

int[] arr = [1, 3, 4, 6, 8, 768, 78, 9]

while (i < count) {

  if (i > 0) {

    arr[i] = count;

  }

  if (i < 15) {

      System.out.println("HEY");

  }

}

it prints Hey too many times

count never gets decremented

The loop is infinite

if statement is incorrect

1/2 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