Professional Documents
Culture Documents
A. {3, 4, 6}
B. {1, 5, 4}
C. 0
D. 10
E. 4
Response:
AP Exam Prep
Question: What values are stored in the array nums after this code segment is run?
nums[2] = nums[4];
nums[3] -= nums[5];
nums[6] = 10 + nums[4];
nums[0]++;
nums[5] += nums[1];
nums[1] -= nums[nums.length-1];
nums[4]--;
nums[2] -= nums[3]; 4 2 -1 1 -1 4 10
CSA 1
Extra Practice
Do This: Use the following table to create an array of US regions and their population in 2010. Then print out
the relationships using formatted Strings as specified in the comment. Finally, update the population array to
the 2019 census data and print the new relationships.
// declare and initialize an int array called population that holds the 2010 population values
// for each region
Population[0] = 55,982,803;
Population[1] = 68,329,004;
Population[2] = 125,580,448;
Population[3] = 78,347,268;
System.out.println( "The " + regions[0] + " region had a population of " + population[0]+ " in 2019");
System.out.println( "The " + regions[1] + " region had a population of " + population[1]+ " in 2019");
System.out.println( "The " + regions[2] + " region had a population of " + population[2]+ " in 2019");
System.out.println( "The " + regions[3] + " region had a population of " + population[3]+ " in 2019");
}
}
CSA 2