WorksheetsOne Dimensional Array
Total questions: 14
Worksheet time: 11mins
ar, given the following declaration:int[] ar = {2, 4, 6, 8 }0, 1, 2, 31, 2, 3, 40, 2, 4, 6For the array:
int stats[3];
What is the range of the index?
0 to 3
0 to 2
1 to 3
0 to 4
int [] nums = {2, 3, 5, 8, 9, 11};
How would you access the fourth element in nums?
nums[4]
nums[3]
nums(4)
nums(3)
What value is at index 1 in this array?
String[] names = {"Mack", "Dennis", "Dee", "Charlie"};
Mack
Dennis
Dee
Charlie
What is the correct way to create an array with these three numbers: 12 8 15
int[] = {12, 8, 15};
int[] nums = {12 8 15};
int[] nums = new {12, 8, 15};
int[] nums = {12, 8, 15};
numbers[i] = 2 * i + 1;
// Which index of the array holds the value of 5?
What does the following segment of code print out?
int[] numArray = { 2, 7, 4, 12, 0, 2 };
System.out.println("Number: " + numArray[2]);
Number: 2
Number: 7
Number: 4
Number: 12
What does the following segment of code print out?
int[] numArray = { 2, 7, 4, 12, 0, 2 };
System.out.println("Number: " + numArray[0]);
Number: 2
Number: 7
Number: 4
Number: 12
What does the following segment of code print out?
int[] numArray = { 2, 7, 4, 12, 0, 2 };
System.out.println(numArray.length);
4
5
6
7
