20 questions
Which of the following is FALSE about arrays on Java
A java array is always an object
Length of array can be changed after creation of array
Arrays in Java are always allocated on heap
What is the length of the following array: byte[] data = { 12, 34, 9, 0, -62, 88 };
1
5
6
12
What are the legal indexes for the array ar, given the following declaration:
int[] ar = {2, 4, 6, 8 };
0, 1, 2, 3
1, 2, 3, 4
2, 4, 6, 8
0, 2, 4, 6
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)
X is ?
Array
Variable
X is ?
Array
variable
What should be written in Comment #1 (i.e. what is the purpose of the first for loop)?
What should be written in Comment #2 (i.e. what is the purpose of the second for loop)?
Write a for loop that create an array of 10 items, each item is 2 more than the previous item.
Which of the following is a correct way to create/initialize an array? Select all that apply.
int ar [ ] = { 1, 2, 3, 4 };
int [ ] ar = new double [ 4 ];
int [ ] ar = { 1, 2, 3, 4 };
int [ ] ar = new int [ 4 ];
int ar [ ] = [ 1, 2, 3, 4 ];