AP CSA arrays key terms
Essential key terms related to arrays for AP Computer Science A, designed for quick study and review.
Quiz(21 preguntas)
1. What is the default value of a boolean array element?
Términos en este set(23)
What is an array?
An array is a collection of elements, all of the same type, stored at contiguous memory locations.
True or false: Arrays can store different data types.
False, because arrays are homogeneous and must contain elements of the same type.
Define the index of an array.
The index refers to the position of an element in an array, starting from 0.
Difference between 1D and 2D arrays.
1D arrays are linear lists, while 2D arrays are grids (rows and columns).
What is the length property of an array?
The length property returns the number of elements in an array.
Fill in the blank: An array is initialized using ________.
Array literal syntax or the 'new' keyword.
Accessing an element at index 3 of an array?
Use arrayName[3] to access the fourth element.
What does 'arrayName.length' return?
It returns the total number of elements in the array.
True or false: Arrays can be resized after creation.
False, because arrays have a fixed size once initialized.
What happens when you access an out-of-bounds index?
It throws an ArrayIndexOutOfBoundsException at runtime.
Difference between an array and an ArrayList.
Arrays have a fixed size; ArrayLists can dynamically resize.
What is a multi-dimensional array?
An array that contains arrays as its elements, e.g., a 2D array.
How to declare an integer array?
int[] arrayName = new int[size]; or int[] arrayName = {value1, value2};
What is the default value of an uninitialized int array?
All elements are initialized to 0 by default.
Fill in the blank: The first element of an array is at index ________.
0.
How do you loop through an array?
Use a for loop: for (int i = 0; i < array.length; i++) {...}
True or false: Arrays can hold primitive data types.
True, because arrays can store any type, including primitives.
What is an array initializer?
Syntax used to initialize an array at the time of declaration.
What is the output of array[0] if array = new int[]{1,2,3}?
The output will be 1, the first element of the array.
Describe how to pass an array to a method.
Declare the parameter as the same type: 'void methodName(int[] array)'.
What is a jagged array?
An array of arrays where each sub-array can have different lengths.
Difference between static and dynamic arrays.
Static arrays have fixed sizes; dynamic arrays can change size.
Fill in the blank: An array's elements can be accessed using the ________ operator.
Index operator [].
Preguntas en este set(21)
1. What is the default value of a boolean array element?
2. Which of the following correctly declares a 2D array?
3. What will happen if you try to access array[5] in an array of size 5?
4. What statement initializes an array with values?
5. Which method can change the size of an array?
6. In which scenario would you use an ArrayList instead of an array?
7. What will be the output of array[1] if array = new int[]{5, 10, 15}?
8. Which keyword is used to create a new array?
9. What is the main advantage of a jagged array?
10. Which of the following is NOT a way to initialize an array?
11. What does array.length represent?
12. How do you call a method that takes an array as a parameter?
13. Which array declaration is correct?
14. What is a common use of arrays in programming?
15. What would array[0] return in a String array with 'hello', 'world'?
16. Which statement is true about arrays?
17. What is the output of array[2] for array = new int[]{3, 6, 9}?
18. How do you create a jagged array?
19. Which statement correctly initializes a 1D array?
20. What is the result of trying to access array[-1]?
21. When would you use an array instead of a List?
Sets relacionados
Abitur Rekursion
Abitur: Abitur Klassen und Objekte
Wiederholung: Abitur Sortierverfahren
Was ist ein Algorithmus Schritt für Schritt
if und Schleifen Notizen
Test: Binärzahlen
Wiederholung: Funktionen
Schleife Alltag Beispiel Begriffe
Crea tu propio set de estudio
Sube un PDF, pega tus notas o describe un tema – la IA genera tarjetas, quizzes y más en segundos.

