Name:     ID: 
 
    Email: 

Arrays

True/False
Indicate whether the sentence or statement is true or false.
 

 1. 

An array is simply a block of variables.
 

 2. 

The use of arrays in ActionScript is optional; there is nothing you can do with an array that you can’t do in some other fashion.
 

 3. 

The following syntax creates an array called myArray.

myArray = new Array();
 

 4. 

It’s not common to use arrays in for loops, with the loop index used as the array index.
 

 5. 

The length property of an array is read only.
 

 6. 

Creating an array and then populating each of its elements with other arrays is called nesting an array.
 

 7. 

A nested array is actually a multidiminsional array.
 

 8. 

Arrays can have any number of dimensions you like.  Below is an example of a 3 x 3 x 5 multidimensional array.

myArray = new Array();
for(i=0; i<3; ++i){
      myArray[i] =  new Array();
      for(j=0; j<3; ++j){
            myArray[i][j] = new Array();
            for(k=0; k<5; ++k)
                  myArray[i][j][k] = "("+i+", "+j+", "+k+")";
      }
}
for(i=0; i<3; ++i){
      for(j=0; j<3; ++j){
            myOutputString = " ";
            for(k=0; k<5; ++k)
                  myOutputString += myArray[i][j][k] + " ";
            trace(myOutputString);
      }
      trace(" "); //blank line
      }
 

 9. 

You can’t access a movie clip properties as an array.
 

 10. 

The eval function gives an absolute path, whereas array notation gives a relative one.
 

Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
 

 11. 

After you have a new array ready, you can add, remove, and access elements in it.  Which of the following code serves as an example of this?
a.
myArray = new Array();
new Array[0] = 100;
trace( myArray[0] + 15);
c.
myArray = new Array();
myArray[0] = 100;
trace( myArray[0] + 15);
b.
myArray = new Array();
myArray[i] = 100;
trace( myArray[0] + 15);
d.
none of the above
 

 12. 

Select the best choice for the following code...

myArray = new Array(“apple”, “bannana”, “cabbage”);
trace(myArray.toString());

a.
This array is being initialized with 3 strings.
c.
This code will not work.
b.
Three elements are given as arguments to the  constructor for the Array object.
d.
both a and b
 

 13. 

Given the following code...

myArray = new Array();
for(i = 0; i<5; ++i){
      myArray[i] = new Array();
      for(j=0; j<5; ++j)
            myArray[i][j] = "["+i+", "+j+"]";
}
for(i=0; i<5; ++i){
      myOutputString = " ";
      for(j=0; j<5; ++j)
            myOutputString += myArray[i][j] + " ";
      trace(myOutputString);
}

The above code is designed to ....
a.
create a three-dimensional array of strings where each string is an (x,y) pair indicating the indexes of that element.
d.
both b and c
b.
create a nested array.
e.
none of the above
c.
create a two-dimensional array of strings where each string is an (x,y) pair indicating the indexes of that element.
 

 14. 

Which of the following statements is true.
a.
The splice method changes the array it’s called on.
c.
Slice and splice do vastly different things.
b.
Slice makes a copy of the array it’s called on.
d.
all statements are true.
 

 15. 

Indicate the most correct statement.
a.
Sort leaves the original array intact and creates a new sorted array.
c.
Sort returns an alphabetically ordered list of values.
b.
Sort does not leave the original array intact; instead, it alters it.
d.
both b and c
 

 16. 

Lexicographic order has to do with ....
a.
the ASCII values of the characters in the string.
c.
the UNICODE values of the characters in the string.
b.
the ANSI values of the characters in the string.
d.
the alphanumeric sort order of variables.
 

 17. 

The following code...

myArray = new Array();
myArray.push("cabbage");
myArray.push("apple");
myArray.push("Billy");
myArray.push("dog-bone");
myArray.push("banana");
trace(myArray.toString());
myArray.sort(Array.CASEINSENSITIVE);
trace(myArray.toString());
a.
will be sorted lexicographically
c.
will be sorted alphanumerically
b.
will be sorted aphabetically
d.
the case of the sorted elements will affect the sort.
 

 18. 

The complement to the pop method is
a.
the shift method
c.
the reverse method
b.
the unshift method
d.
the push method
 

 19. 

Consider the following code and indicate the most correct choice.

myArray = new Array();

a.
the ‘new’ keyword is used to create a new object called ‘myArray’
c.
a new array object is being constructed through the use of the keyword ‘new’
b.
the ‘new’ keyword is used to create a new object called ‘Array’
d.
both a and c
 

 20. 

Indicate the output for the following code...
myArray = new Array();
myArray[0] = 100;
myArray[3] = 100;
myArray[5] = 100;
trace(myArray);
a.
100,100,100
c.
undefined
b.
100,undefined,undefined,100,undefined,
100
d.
this code will not work.  It will produce and error message.
 

Matching
 
 
Each array object comes with several predefined methods. Match the correct method definition with each array method.
a.
Array.toString
g.
Array.shift
b.
Array.join
h.
Array.unshift
c.
Array.concat
i.
Array.sort
d.
Array.reverse
j.
Array.sortOn
e.
Array.pop
k.
Array.slice
f.
Array.push
l.
Array.splice
 

 21. 

Reverses the order of all elements in an array.
 

 22. 

Returns a string that represents the elements in an array.
 

 23. 

Joins all the elements of an array into a string
 

 24. 

Adds and removes elements from an array
 

 25. 

Joins two strings and returns the conglomeration.
 

 26. 

Removes the last elements from an array and returns its value
 

 27. 

Removes a section of an array and returns it as a new array.
 

 28. 

Removes the first element from an array and returns its value
 

 29. 

Sorts an array based on one element of the array
 

 30. 

Adds a new element to the end of an array and returns the array’s length
 

 31. 

Sorts an Array
 

 32. 

Adds a new element to the beginnning of an array and returns the array’s length
 



 
Submit          Reset Help