Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an integer array of size 5.
Java
int[] numbers = new int[[1]];🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to access the third element of the array.
Java
int third = numbers[[1]];🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code to correctly print all elements of the array.
Java
for (int i = 0; i < numbers.[1]; i++) { System.out.println(numbers[i]); }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create an array of squares for numbers 1 to 5.
Java
int[] squares = new int[5]; for (int [1] = 0; [2] < 5; [1]++) { squares[[1]] = ([1] + 1) * ([1] + 1); }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a new array with elements doubled from the original.
Java
int[] doubled = new int[numbers.[1]]; for (int [2] = 0; [2] < numbers.length; [2]++) { doubled[[2]] = numbers[[2]] [3] 2; }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
