0
0
Javaprogramming~15 mins

Array declaration and initialization 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.

Java
int[] [1];
🎯 Drag options to blanks, or click blank then click option
Aarray
Bnumbers
Clist
Dvalues
Attempts:
3 left
2fill in blank
medium

Complete the code to initialize the array with 5 elements.

Java
int[] numbers = new int[[1]];
🎯 Drag options to blanks, or click blank then click option
A3
B0
C10
D5
Attempts:
3 left
3fill in blank
hard

Fix the error in the array initialization syntax.

Java
int[] numbers = [1] {1, 2, 3, 4, 5};
🎯 Drag options to blanks, or click blank then click option
Anew int[]
Bint[]
Cnew int
Dint
Attempts:
3 left
4fill in blank
hard

Fill both blanks to declare and initialize an array with values 10, 20, 30.

Java
int[] [1] = [2] {10, 20, 30};
🎯 Drag options to blanks, or click blank then click option
Ascores
Bnew int[]
Cvalues
Dint[]
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create an array of strings with names and print the first element.

Java
String[] [1] = [2] {"Alice", "Bob", "Charlie"};
System.out.println([3][0]);
🎯 Drag options to blanks, or click blank then click option
Anames
Bnew String[]
Dlist
Attempts:
3 left