Monday
Read and solve the exercises found in [arrays](../../topics/03 programflow/array.md)
Peer instruction
Question 1
Which of the following correctly declares and initialises an array?
int array[] = {1,2,3,4,5};short array[] = new short[4];char array = {'a', 'b', 'c', 'd', 'e'};double array[] = new double{11.1, 22.2, 33.3};String array[] = new String[]{"Java", "Fortran", "C++"}
Question 2
Which of the following correctly increments all the elements of array
for (int i = 0; i < array.length(); i++) array[i]++;for (int i = 0; i < array.length; i++) array[i]++;for (int i = 0; i < array.length; i++) array[i++]++;array[0..array.length]++;array++;
Question 3
What will the value of array be?
3, 4, 5, 6, 71, 2, 2, 3, 33, 2, 2, 3, 31, 2, 2, 3, 73, 2, 2, 3, 7
Last updated
Was this helpful?