# Quiz: Arrays: Working with groups of objects

After doing all parts of this lesson you should be able to answer these questions.

1. How do you create an array?

Just like creating a variable, but check the box for array. Then you will give it multiple values.

2. What data types can be made into an array?

All data types, including any of the classes.

3. An array is declared as String[] words=new String[] {"please", "thank you", "you're welcome"}; What is the value of words[1]?

"thank you" Remember numbering starts with 0.

4. One array is declared as String[] people=new String[] {"Sam", "Dave", "Amy"};
Another array has the ages of the 3 people: Integer[] ages=new Integer[] {12,6,20};
Because there is a one to one correspondence between these two arrays they are called _____ arrays.

parallel

5. An array is declared as String[] people=new String[] {"Sam", "Dave", "Amy"};
What is the value of people.getLength?

3: The length of an array is the number of elements.

6. An array is declared as String[]days=new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; Which is the best description of this code:
for(Integer i=1; i<6; i++) {
bunny.say(days[i];
}

The bunny says "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"

7. What is the correct order of the steps to create an array:
select a class or type,
drag a variable tile to the code window
check array

Answer: 1. drag a variable tile to the code window, 2. select a class or type and check array (do in any order), 3. add items to the array.

8. An array is declared as String[] affirm=new String[] {"Yes", "You bet", "OK","Right"};
Is this a valid command: this.witch.say(affirm);

No, you have to use a subscript: this.witch.say(affirm[i]);

9. Which of the statements below is correct to declare an array of bipeds?
Biped[]actors=new Biped[] { "this.ogre", "this.witch", "this.alien" };
Biped[]actors=new Biped[] { "ogre", "witch","alien" };
Biped[]actors=new Biped[] { this.ogre, this.witch, this.alien };

The last one

10. What does this code do?

The camel says "Hello", the gopher says "What's up?", the elk says "Yo!" and the fox says "Hey!"

Please review the material for any questions you miss.