0
0
Javaprogramming~15 mins

One-dimensional arrays in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an integer array named numbers with size 5.

Java
int[] numbers = new int[[1]];
🎯 Drag options to blanks, or click blank then click option
A0
B10
C5
D1
Attempts:
3 left
2fill in blank
medium

Complete the code to assign the value 10 to the first element of the array numbers.

Java
numbers[[1]] = 10;
🎯 Drag options to blanks, or click blank then click option
A0
B1
C5
D-1
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to print the length of the array numbers.

Java
System.out.println(numbers[1]);
🎯 Drag options to blanks, or click blank then click option
A.length
B.size()
C.length()
D.count
Attempts:
3 left
4fill in blank
hard

Fill both blanks to create an array of strings named fruits with 3 elements and assign "Apple" to the first element.

Java
String[] fruits = new String[[1]];
fruits[[2]] = "Apple";
🎯 Drag options to blanks, or click blank then click option
A3
B1
C0
D5
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create an integer array named scores, assign 100 to the last element, and print it.

Java
int[] scores = new int[[1]];
scores[[2]] = 100;
System.out.println(scores[3]);
🎯 Drag options to blanks, or click blank then click option
A4
B3
C[scores.length - 1]
D[3]
Attempts:
3 left