Challenge - 5 Problems
Array Length Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate2:00remaining
What is the output of this Java code using array length?
Consider the following Java code snippet. What will be printed when it runs?
Java
public class Main { public static void main(String[] args) { int[] numbers = {5, 10, 15, 20, 25}; System.out.println(numbers.length); } }
Attempts:
2 left
💻 code output
intermediate2:00remaining
What is the output when accessing length of a multidimensional array?
Look at this Java code. What will it print?
Java
public class Main { public static void main(String[] args) { int[][] matrix = new int[3][4]; System.out.println(matrix.length); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
What happens if you try to assign to the length property of an array?
What will happen when this Java code runs?
Java
public class Main { public static void main(String[] args) { int[] arr = {1, 2, 3}; arr.length = 5; System.out.println(arr.length); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
What is the output of this code accessing length of a null array?
What will this Java program print or do?
Java
public class Main { public static void main(String[] args) { int[] arr = null; System.out.println(arr.length); } }
Attempts:
2 left
🧠 conceptual
expert2:00remaining
How many elements are in the array after this code runs?
What is the number of elements in the array 'data' after executing this code?
Java
public class Main { public static void main(String[] args) { int[] data = new int[10]; data = new int[5]; System.out.println(data.length); } }
Attempts:
2 left
