Challenge - 5 Problems
Array Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 code output
intermediate2:00remaining
Output of array initialization and access
What is the output of the following Java code?
Java
public class Main { public static void main(String[] args) { int[] numbers = new int[3]; numbers[0] = 5; numbers[1] = 10; numbers[2] = 15; System.out.println(numbers[1]); } }
Attempts:
2 left
💻 code output
intermediate2:00remaining
Output of array initialization with values
What will be printed by this Java program?
Java
public class Main { public static void main(String[] args) { String[] fruits = {"Apple", "Banana", "Cherry"}; System.out.println(fruits.length); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of multi-dimensional array initialization
What is the output of this Java code?
Java
public class Main { public static void main(String[] args) { int[][] matrix = new int[2][3]; matrix[0][1] = 7; matrix[1][2] = 9; System.out.println(matrix[1][2] + matrix[0][1]); } }
Attempts:
2 left
💻 code output
advanced2:00remaining
Output of array default values
What will this Java program print?
Java
public class Main { public static void main(String[] args) { boolean[] flags = new boolean[4]; System.out.println(flags[2]); } }
Attempts:
2 left
🧠 conceptual
expert3:00remaining
Number of elements in a jagged array
Consider the following Java code snippet. How many elements does the jagged array contain in total?
Java
public class Main { public static void main(String[] args) { int[][] jagged = new int[3][]; jagged[0] = new int[2]; jagged[1] = new int[4]; jagged[2] = new int[3]; } }
Attempts:
2 left
