WorksheetsArrays += Chan
Total questions: 12
Worksheet time: 2hrs 2mins
Given the following code segment what will be returned when you execute: getIndexOfLastElementSmallerThanTarget(values,-13);
A. -1
B. -15
C. 1
D. You will get an out of bounds error.
Given the following code segment what would be the elements of a when you execute: doubleLast();
A. {-40, -30, 4, 16, 32, 66}
B. {-40, -30, 4, 8, 16, 32}
C. {-20, -15, 2, 16, 32, 66}
D. {-20, -15, 2, 8, 16, 33}
What is returned from mystery when it is passed {10, 30, 30, 60}?
A. 17.5
B. 30.0
C. 130
D. 32
E. 32.5
What is the output of the code segment?
(a)
Select all missing code that works.
int i = ans.length; i >= 0; i--
int i = ans.length-1; i >= 0; i--
int i = ans.length-1; i > 0; i--
int i = 0; i < ans.length; i++
int i = 0; i <= ans.length; i++
Given an array of length 5, what are the indexes of the middle three elements?
4
2
1
0
3
Given an array of length 3, called arr, what is the middle element?
arr[1]
2
1
arr[2]
Select all options that would give you an error.
Assume the Zoog and the Car objects have working class definitions.
float[] numbers = new float[5 + 6];
int num = 5; float[] numbers = new int[num];
int num = (5 * 6)/2; float[] numbers = new float[num = 5];
int num = 5; Zoog[] zoogs = new Zoog[num * 10];
float num = 5.2; Car[] cars = new Car[num];
What is the output of the given code segment
2
-12
-3
None of the above
What is the output of the given code segment?
Null Pointer Exception
3
2
0
How many objects have been instantiated?
22
33
11
44
None of the above.
Which of the following creates an array of 10 doubles called prices?
A. int[] prices = new int[10];
B. double[] prices = new double[10];
C. double[] prices;
D. double[10] prices = new double[];
