Enhanced For Loops

Enhanced For Loops

Assessment

Flashcard

Computers

10th - 12th Grade

Practice Problem

Hard

Created by

Wayground Content

FREE Resource

Student preview

quiz-placeholder

5 questions

Show all answers

1.

FLASHCARD QUESTION

Front

What is the correct code to put in place of /*******/ in the Enhanced For Loop to sum all the values in an array of ints called values ?
int sum = 0;
for(int value: /*******/)
{
       sum = sum + value;
}

Back

values

2.

FLASHCARD QUESTION

Front

What is the correct code to put in place of /*******/ in the Enhanced For Loop to sum all the values in an array of ints called values ?
int sum = 0;
for( /*******/ : values)
{
       sum = sum + value;
}

Back

int value

3.

FLASHCARD QUESTION

Front

Assume that an array of ints called values has been initialized. We want to write an Enhanced For Loop to sum all the values. What is the correct code to put in place of /*******/
int sum = 0;
for( int value : values)
{
       /*******/
}

Back

sum += value;

4.

FLASHCARD QUESTION

Front

What is the correct code for an enhanced for loop to say Hello to each name in the array of Strings called friends?
for(/*********/)
{
     System.out.println("Hello " + friend);
}

Back

String friend:friends

5.

FLASHCARD QUESTION

Front

Assume that an array of Strings called friends has been created and initialized. We want to write an enhanced for loop that says Hello to each name in the array. What is the correct code that goes in place of /*********/? for(String friend:friends) { /***********/ }

Back

System.out.println("Hello " + friend);

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?