Answer:
public int sum(ArrayList array) {
int total = 0;
for(int i=1;i<array.size();i+=2){
total += array.get(i);
}
return total;
}
Explanation:
Step 1 define the method and variables
public int sum(ArrayList array) {
int total = 0;
Step 2 loop over the array index from 1 to array size step 2 (Keep in mind if you have step 2 beginin in 1 you loop the odd index
for(int i=1;i<array.size();i+=2){
Step 3 Acumulate the total of data with odd index
total += array.get(i);
Step 4 Return de total
return total;
Example
If you use the array [4,6,2,10]
you get as total the sum of 6 and 10 that correspond to the index 1 and 3 respective
total = 16