Test: Computer Science

Consider the following code:

for(int i = 1; i <= 10; i++) {

     for(int j = 0; j < (20 - i * 2) / 2; j++) {

          System.out.print(" ");

     }

     for(int j = 0; j < i * 2; j++) {

          System.out.print("*");

     }

     for(int j = 0; j < (20 - i * 2) / 2; j++) {

          System.out.print(" ");

     }

     System.out.println();

}

1.

Describe the output of the code above.

An arrow pointing upward, having a base 20 characters wide and a top that is 2 characters wide.

A left-facing arrow with a large base of 20 characters in size and a point that is 1 character wide.

An arrow pointing upward, having a base 20 characters wide and a top that is 1 character wide.

An arrow pointing downward, having a base 20 characters wide and a top that is 2 characters wide.

A right-facing arrow with large base of 20 characters in size and a point that is 2 characters wide.

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