1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What is an array?
A data structure that stores a collection of elements, all of the same type.
What is the index of the first element in an array?
How do you declare an array in Java?
You can declare an array using 'int[] numbers;' or 'int numbers[];'. The preferred method is 'int[] numbers;'.
What must an array be initialized with?
An array must be initialized with a specific size or with values.
How do you access the first element of an array named 'numbers'?
You access it using 'numbers[0]'.
What does the length property of an array represent?
It gives the number of elements in the array.
How do you declare a 2D array in Java?
You can declare it using 'int[][] matrix = new int[3][4];'.
What does the enhanced for loop do?
It simplifies iteration over arrays.
How are arrays passed to methods in Java?
Arrays are passed by reference, allowing methods to modify the original array.
What exception is thrown when accessing an invalid index of an array?
ArrayIndexOutOfBoundsException.
Can arrays store objects in Java?
Yes, arrays can store objects, not just primitive types.
What happens when an array is instantiated in Java?
Java automatically initializes the components to their default values; for integers, this is 0.
What is the syntax for declaring an array with a fixed number of components?
First the data type followed by brackets, e.g., 'int[] alhs = new int[6];'.
What is the correct declaration for multiple arrays of the same type?
Use 'int[] alpha, beta;' to ensure both variables are arrays.