# Subgoals

## Section9.21Arrays-WE8-P1

### Subsection9.21.1Subgoals for Evaluating Arrays

1. Set up array from 0 to size-1
2. Evaluate data type of statements against array
3. Trace statements, updating slots as you go
1. Remember assignment subgoals

### Subsection9.21.2Arrays-WE8-P1

#### ExercisesExercises

##### 1.
Q45: What are the contents of array alpha after this code has been executed?
int [] alpha = {10, 20, 30, 40, 50, 60, 70};
int start = alpha[alpha.length-1];
for (int i = 1; i < alpha.length; i++)  {
alpha[i] = alpha[i-1];
}
alpha[0] = start;

• {20, 30, 40, 50, 60, 70, 70}
• {20, 30, 40, 50, 60, 70, 10}
• {10, 20, 30, 40, 50, 60, 70}
• {10, 10, 20, 30, 40, 50, 60}
• {70, 10, 10, 10, 10, 10, 10}
##### 2.
Q46: What are the contents of array beta after this code has been executed?
int [] beta = {10, 20, 30, 40, 50, 60, 70};
for (int i = 1; i < beta.length; i++)  {
beta[i] = beta[i-1])
}

• {20, 30, 40, 50, 60, 70, 70}
• {20, 30, 40, 50, 60, 70, 10}
• {10, 20, 30, 40, 50, 60, 70}
• {10, 10, 20, 30, 40, 50, 60}
• {70, 10, 20, 30, 40, 50, 60}
##### 3.
Q47: What are the contents of array gamma after this code has been executed?
int [] gamma = {10, 20, 30, 40, 50, 60, 70};
for (int i = 0; i < gamma.length; i++)  {
gamma[i] = gamma[i+1])
}

• {20, 30, 40, 50, 60, 70, 70}
• {20, 30, 40, 50, 60, 70, 10}
• {10, 20, 30, 40, 50, 60, 70}
• {10, 10, 20, 30, 40, 50, 60}
• IndexOutOfBounds Exception